So to get the distance, you have to divide your result by two. With that information we can now calculate the distance!īut we’re not done yet! Remember that the echo pulse indicates the time it takes for the signal to be sent and reflected back. To calculate the distance we need to convert the speed of sound into cm/µs. Of course it’s the speed of sound! It is 340 m/s. Now let’s calculate how far the object is from the sensor. Suppose we have an object in front of the sensor at an unknown distance and we receive a pulse of 500µs width on the echo pin. Let us take an example to make it more clear. Thus a pulse of 38ms indicates no obstruction within the range of the sensor. If those pulses are not reflected back, the echo signal times out and goes low after 38ms (38 milliseconds). Meanwhile the echo pin goes HIGH to initiate the echo-back signal. These eight ultrasonic pulses travel through the air away from the transmitter. This 8-pulse pattern is specially designed so that the receiver can distinguish the transmitted pulses from ambient ultrasonic noise. In response, the sensor transmits an ultrasonic burst of eight pulses at 40 kHz. It all starts when the trigger pin is set HIGH for 10µs. How Does HC-SR04 Ultrasonic Distance Sensor Work? By measuring the time the Echo pin stays high, the distance can be calculated. By setting this pin to HIGH for 10µs, the sensor initiates an ultrasonic burst.Įcho pin goes high when the ultrasonic burst is transmitted and remains high until the sensor receives an echo, after which it goes low. Trig (Trigger) pin is used to trigger ultrasonic sound pulses. You can connect it to the 5V output from your Arduino. VCC supplies power to the HC-SR04 ultrasonic sensor.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |