loading

With the Christmas here, we all want to know how far Santa is, and what better fit for this, than Arduino with Ultrasonic Ranger.

In this Instructable, I will show you how easy it is to connect Ultrasonic Sensor to Arduino and control it with the help of Visuino - an easy to use graphical development environment for Arduino.

Please note that the annotation on some of the pictures in this Instructable will work correctly on some browsers only after you click on the image to expand it.

Please make sure you click on the image to see the annotation showing the correct spot on the image!

Step 1: Components

  1. One Arduino compatible board (I use Arduino Nano, because I have one, but any other will be just fine)
  2. One Ultrasonic Ranger Sensor Module - I used HC-SR04, but US-015, or very much any other will also work
  3. 4 Female-Female jumper wires

Step 2: Connect the Ultrasonic Ranger to Arduino

  1. Connect Ground(Black wire), Power(Red wire), Trigger(Green wire), and Echo(Yellow wire) to the Ultrasonic Ranger Sensor Module (Picture 1)
  2. Connect the other end of the Power wire(Red wire) to the 5V power pin of the Arduino board(Picture 2)
  3. Connect the other end of the Ground wire(Black wire) to Ground pin of the Arduino board(Picture 2)
  4. Connect the other end of the Trigger wire(Green wire) to Digital pin 2 of the Arduino board(Picture 3)
  5. Connect the other end of the Echo wire(Yellow wire) to Digital pin 3 of the Arduino board(Picture 3)
  6. Picture 4 shows where are the Ground, 5V Power, Digital 2, and Digital 3 pins of the Arduino Nano

Step 3: Start Visuino, and Select the Arduino Board Type

To start programming the Arduino, you will need to have the Arduino IDE installed from here: http://www.arduino.cc/.

Please be aware that there are some critical bugs in Arduino IDE 1.6.6. Make sure that you install 1.6.7 or 1.6.5, otherwise this Instructable will not work!

The Visuino: https://www.visuino.com also needs to be installed.

  1. Start Visuino as shown in the first picture
  2. Click on the "Tools" button on the Arduino component (Picture 1) in Visuino
  3. When the dialog appears, select Arduino Nano as shown in Picture 2

Step 4: In Visuino: Add and Connect Ultrasonic Ranger Component

  1. Type "sonic" in the Filter box of the Component Toolbox then select the "Ultrasonic Ranger(Ping)" component (Picture 1), and drop it in the design area
  2. Connect the "Ping" pin of the UltrasonicRanger1 component to the "Digital" input pin of the Digital[ 2 ] channel of the Arduino component (Picture 2)
  3. Connect the "Out" pin of the Digital[ 3 ] channel of the Arduino component to the "Echo" input pin of the UltrasonicRanger1 component (Picture 3)
  4. Connect the "Out" output pin of the UltrasonicRanger1 component to the "In" input pin of the Serial[ 0 ] channel of the Arduino component(Picture 4)

Step 5: Generate, Compile, and Upload the Arduino Code

  1. In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
  2. In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)

Step 6: And Play...

  1. In Visuino select the Serial Port and click the Connect button (Picture 1)
  2. In the Serial Terminal you will see the distance measured by the sensor (Picture 2)
  3. If you click on the Scope Tab you can also see the values plotted in the Scope (Picture 3)

Congratulations! You have learned how to connect Ultrasonic Ranger to Arduino, and how to program it with Visuino.

You can see the connected and running Ultrasonic Ranger sensor on Picture 4.

On Picture 5 you can see the complete Visuino diagram.

Also attached is the Visuino project, that I created for this Instructable. You can download and open it in Visuino: https://www.visuino.com

<p>Hi, thanks for the great instructions. I was wondering if you could help me out with the code to ad a distance limit and trigger an alarm (e.g. a led/ buzzer). For example if the distance reaches below 10cm it will trigger the alarm. In advance many thanks for your help.</p>
<p>Thanks alot</p>
<p>Thanks alot</p>

About This Instructable

7,987views

146favorites

License:

More by BoianM:Program Arduino UNO With Visuino to Draw on ILI9341 TFT Touchscreen Display Shield With Pen Assemble Kuman Wi-Fi Robot With Camera and Manipulator Arduino and Visuino: Long Distance Remote Light Sensor With RFM95W/RFM98W Makerfabs LoRa Shields  
Add instructable to: