Ultrasonic Sensor HC-SR04 And Arduino Tutorial
Maybe your like
In this Arduino Tutorial we will learn how the HC-SR04 Ultrasonic Sensor works and how to use it with the Arduino Board. It emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance.
PART 1 - Schematic
The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board. We need: 1 x Arduino NANO/UNO: LINK eBay 1 x HC-SR04 module: LINK eBay 1 x i2c LCD: LINK eBay 1 x Jump wires: LINK eBay 1 x Breadboard: LINK eBay
PART 2 - Distance CODE - serial print
In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled. We print the values on the serial monitor or LCD. See codes below.
Download serial monitor example code:Upload the code and make the connections. Then open the serial monitor at 9600 bauds and you will have the results printed to the serial monitor. Or go below and download the code with the i2c LCD.
PART 3 - Distance CODE - results on LCD Download LCD example code:Upload the code and make the connections. Then open the serial monitor at 9600 bauds or just see the results on the LCD screen.
←PREVIOUS TUTORIAL NEXT TUTORIAL→ Help me by sharing this post ShareTag » Arduino Hc-sr04 Code
-
Ultrasonic Sensor HC-SR04 With Arduino Tutorial
-
Getting Started With The HC-SR04 Ultrasonic Sensor - Arduino Cloud
-
Ultrasonic Sensor HC-SR04 And Arduino - Complete Guide
-
Complete Guide For Ultrasonic Sensor HC-SR04 With Arduino
-
Sử Dụng Cảm Biến Khoảng Cách HC-SR04
-
Arduino - Ultrasonic Sensor - Tutorialspoint
-
HC-SR04 Ultrasonic Sensor With Arduino Tutorial (5 Examples)
-
Ultrasonic Sensor | Arduino Tutorial
-
How HC-SR04 Ultrasonic Sensor Works & How To Interface It With ...
-
Ultrasonic Sensor HC-SR04 And Arduino Tutorial - YouTube
-
Ultrasonic Sensor HC-SR04 With Arduino Tutorial
-
Arduino Lib For HCSR04 Ultrasonic Sensor - GitHub
-
Using The HC-SR04 Ultrasonic Distance Sensor With Arduino