Skip to content
kristopher edited this page Sep 12, 2010 · 19 revisions

A Guide to Using a Range Finder with RAD

What It Is

A range finder is a fun little device with two small speakers, one being a transmitter and one a receiver. The transmitter sends out
an ultrasonic pulse(ping). The receiver picks the echo(reflection) of that pulse. The time from the transmission of the pulse to the reception of the echo with a bit of calculation gives you the range(distance).

It works the same way as Active Sonar if you are interested in a more in depth explanation.

What It’s Good For

  • Robotics

  • Sonar

  • As a MIDI interface

How to Use It – General

How to Use It – RAD

RAD code to be uploaded to your Arduino.


class RangeFinder < ArduinoSketch

  serial_begin

  external_vars :sig_pin => 'int, 7'

  def loop
    serial_println(ping(sig_pin))
    delay(200)
  end
end

Simple ruby script using ruby-serialport to view the output of the range finder.


require "serialport.so"

port_str = "/dev/tty.usbserial-FTAJM79K"  #may be different for you
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE

serial_port = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)

loop do
  puts serial_port.gets
end

How it Works

From range finder
From range finder
From range finder

How to Use It – Advanced

Where to Get It

You can pick one up at the Parallax website or at a local Radio Shack.

Read More