With the Christmas here, we all want to know how far Santa is, and what better fit for this, than Arduino with Ultrasonic Ranger.
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
Step 2: Connect the Ultrasonic Ranger to Arduino
- Connect Ground(Black wire), Power(Red wire), Trigger(Green wire), and Echo(Yellow wire) to the Ultrasonic Ranger Sensor Module (Picture 1)
- Connect the other end of the Power wire(Red wire) to the 5V power pin of the Arduino board(Picture 2)
- Connect the other end of the Ground wire(Black wire) to Ground pin of the Arduino board(Picture 2)
- Connect the other end of the Trigger wire(Green wire) to Digital pin 2 of the Arduino board(Picture 3)
- Connect the other end of the Echo wire(Yellow wire) to Digital pin 3 of the Arduino board(Picture 3)
- 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!
Step 4: In Visuino: Add and Connect Ultrasonic Ranger Component
- 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
- Connect the "Ping" pin of the UltrasonicRanger1 component to the "Digital" input pin of the Digital[ 2 ] channel of the Arduino component (Picture 2)
- Connect the "Out" pin of the Digital[ 3 ] channel of the Arduino component to the "Echo" input pin of the UltrasonicRanger1 component (Picture 3)
- 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
- In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE
- In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2)
Step 6: And Play...
- In Visuino select the Serial Port and click the Connect button (Picture 1)
- In the Serial Terminal you will see the distance measured by the sensor (Picture 2)
- 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.