Ultrasound is an oscillating sound pressure wave with a frequency greater than the upper limit of the human hearing range.
Bats use ultrasound to navigate. They can hear sounds with high frequency. By making sound and hearing echo they determine the distance of objects in their flying area. This is called echolocation.
Their ability to catch flying insects while flying full speed in pitch darkness is astounding. Their sophisticated echolocation permits them to distinguish between a moth (supper) and a falling leaf.
Our ultrasonic sensor has a trigger Tx and a receiver Rx (a microphone). Often it is used, for its appearance, in the little robots as eyes.
Speed = Space / Time
Space = Speed * Time
the speed of sound in air is 343.8 m/s
then, using microseconds and centimeters :
Space = 0,03438 * Time
divided by 2, because ultrasounds go and come back
distance = 0,03438 * Time / 2
distance = 0,01719 * Time
duration = 0
distance = 0
SWITCH ON (5 Volt) _trigger
SWITCH OFF (0 Volt) _trigger
in the variable duration
put the duration of the pulse on the pin: _receiver
the variable distance is equal to the formula duration*0.01720
write on the serial: distance:_cm distance