![]() ![]() Let’s write an Arduino program to read the distance measured by the sensor. NOTE: Technically, we can use the same pin for both the trigger pin and the echo pin, as the input mode and the output mode are used at different times. Other than the power pins, we can connect the trigger pin and the echo pin of the HC-SR04 to any digital I/O pins of the Arduino. The connection is rather straightforward. We can find out how much time the pulses of sound wave take to travel forward and backward by measuring how long the ‘echo’ pin is at the HIGH state. Then, the sensor sets the ‘echo’ pin to HIGH until the reflected signal arrives. When a microcontroller like Arduino sets the ‘trigger’ pin to the HIGH state for 10 microseconds, the sensor emits a few pulses of sound wave. To start the measurement, we need to make the sensor emit some sound wave. ![]() The ‘trigger’ pin is for starting the measurement, and the ‘echo’ pin is for outputting the measured result. The HC-SR04 is an ultrasound transceiver, which means it emits sound wave and detects the reflected wave. 10 ohm resistors x 3 (for assignment only).LED lights of different colors x 3 (for assignment only).HC-SR04 with the Arduino Materials and Tools In this tutorial, we will connect the HC-SR04 to an Arduino, and use this setup to measure the distance between the sensor and a nearby obstacle. Therefore, HC-SR04 is ideal for adding collision avoidance capability to a robot. It can measure distance from 2 cm to about 500 cm. HC-SR04 is an inexpensive ultrasonic sensor. By measuring the time required for the pulse to travel to the object and travel back to the transceiver, we can calculate the distance between the object and the transceiver with the speed of sound. If the sound wave hits an object, the sound wave is reflected back to the transceiver. A sonar transceiver sends a pulse of sound wave. The working principle of active sonar is quite simple. Sound navigation and ranging, also known as Sonar, uses sound wave to detect objects.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |