Fun Project With HC-SRO4 Ultrasonic Sensor
by ElectronicSciTech in Circuits > Arduino
623 Views, 3 Favorites, 0 Comments
Fun Project With HC-SRO4 Ultrasonic Sensor
This is a Fun project, where you can play around with the HC-SRO4 Ultrasonic Sensor, if you are just getting started with the Ultrasonic Sensor.
At the end of this project, you will have interfaced your Arduino UNO with the HC-SRO4 Sensor. Additionally, it will also be interfaced with the LED, based on the distance.
Get Your Supplies!
What you need for a working system:
- Arduino UNO along with USB Cable
- HC-SRO4 Ultrasonic Sensor
- Breadboard
- Male-to-male connecting wires
- Male-to-female connecting wires
- 3V LED
- 330 Ohm Resistor (4 bands Color code: Orange-Orange-Brown-Gold.)
Software used:
- Arduino IDE
Get Your Programming Done!
- If you know Arduino Programming, then this step will be much easier for you and you can configure the code on your own also.
- You can find the files for the code below and the image of the code above (Note that you have to download these files and open it on Arduino IDE. So before starting this project, you must have the Arduino IDE installed. For the installation, you can refer to youtube videos (or) to the Arduino official website (i.e. https://www.arduino.cc/) (or) if you are facing any issues, you can ask in the Comments and Questions section).
- After this, insert the USB cable in the Arduino to your laptop/pc. You can use the image above or the file of the code below and upload your code.
- Note that when you download the (.ino) file, you have to go to Arduino IDE and open the file. Arduino will ask you to create a folder and you can go ahead and create a folder and start using the (.ino) file.
Downloads
Get Your Connections Done!
- Once the code is uploaded to your Arduino UNO, unplug the USB cable from your laptop/pc. Now we shall start the connections.
- Connect the VCC from the sensor to the 5V in the Arduino UNO in the Power section (using a male-to-female wire).
- Connect the GND from the sensor to any one GND in the Power section of the Arduino UNO.
- Connect the Echo pin from the sensor to the Digital Pin (DO) number 6.
- Connect the Trig pin from the sensor to the Digital Pin (DO) number 5.
- Connect the Digital Pin (DO) number 8 from the Arduino UNO to the +ve rail in the breadboard.
- Connect the other GND pin from the Arduino to the -ve rail in the breadboard.
- Connect the 3V LED and the 330 Ohm resistor in the breadboard as shown in the schematic and the picture.
Get Your Project Done!
Now, insert the USB cable connected to the Arduino in your laptop/pc , once the Connections are done.
Your Project is Done!
You can also configure the distance in the code.
You will see that if the distance of the object is less than 20cm, the LED lights up. Else it does not light up,
Thank you for viewing this Instructable. Please share it and feel free to post the photos of your prototype. If you have any issues pertaining to this project, let me know in the Comments and Questions Section.