Home > Arduino, electronics, library > Arduino Library for the SRF04 Ultrasonic Ranger

Arduino Library for the SRF04 Ultrasonic Ranger

I started a Google code project to share an Arduino library for the SRF04 Ultrasonic Ranger (distance sensor).

Overview:

This project is a free initiative to create an Arduino library for the SRF04 Ultrasonic Ranger. The main goal is to provide a library that simplifies the usage of this particular sensor in Arduino projects.

Range: approx. 3 to 300 cm

How the sensor works:

  1. You apply a short 10uS pulse to the trigger input to start the ranging.
  2. The SRF04  sends out an 8 cycle burst of ultrasound at 40khz and raises its echo line high.
  3. It then listens for an echo, and as soon as it detects one it lowers the echo line again.
  4. The echo line is  a pulse whose width is proportional to the distance to the object.
  5. By timing the pulse it is possible to calculate the range.

Library usage:

  1. Download the source
  2. Place the DistanceSRF04 folder in your Arduino1.0+ “libraries” folder
  3. Open example sketch: “file”, “Examples”, “DistanceSRF04”, “Centimeter” (or “Inch” or “Time”)
  4. Connect echoPin to pin 2, trigPin to pin 3 (and connect Vcc and GND)
  5. Compile & upload code
  6. Sensor data should be arriving over the serial port

More info & download: http://code.google.com/p/srf04-library/

Advertisements
  1. 29 May 2013 at 11:38 pm

    I almost never leave a response, but after reading through a few
    of the responses on Arduino Library for the SRF04 Ultrasonic Ranger | The musings
    of Jeroen Doggen. I actually do have 2 questions for you if you do not
    mind. Could it be only me or do some of these remarks come across
    like they are coming from brain dead visitors?

    😛 And, if you are writing on other online sites,
    I would like to follow everything new you have to post.
    Could you post a list of every one of all your public pages like your Facebook page, twitter
    feed, or linkedin profile?

    • jeroendoggen
      30 May 2013 at 1:33 pm

      Are you a bot?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: