How to Use Ultrasonic Sensors with the Arduino

I’ve made my first video tutorial! I obtained some SR-04 ultrasonic sensors quite cheaply, and I’ve been learning how to use them with the Arduino, with good results. I’ve created a tutorial covering how to get the proper libraries and how to use the basic functions in the Arduino IDE to interface with the sensor.

Here’s the steps (covered in the video) on how to get NewPing, a library created for controlling ultrasonic sensors, up and running with the Arduino IDE:

  1. Use this link to download the NewPing Library:
  2. Click “Download NewPink v1.7” and save the .zip file.
  3. Open the Arduino IDE, and go to ‘Sketch>Include Library>Add .ZIP Library’ and then navigate to where you saved the .zip download, and click ‘open.’
  4. Go to ‘Sketch>Include Library’ again and scroll all the way down to the bottom and select NewPing.
  5. The NewPing library will now be included in your sketch.
  6. For some sample sketches and documentation of NewPing, look here:!syntax.

For code sample written in the tutorial, click here.

P.S. – Yesterday was the first anniversary of this blog (this is my 48th post)! 😀

ultrasonic sensor schematic