Ultrasonic and Infared Rangefinders - MDHSRobotics/TeamWiki GitHub Wiki
Sensor Types
##Ultrasonic Sensors Ultrasonic sensors work by emitting a pulse of sound(called a "ping"), normally at 40 kHz, and then measuring the amount of time that it takes to receive that same sound wave. The sound wave always travels at the same speed, so the time it takes for the sound wave to return(called an "echo") can be used to measure the distance between the sensor and what is in front of it. This is represented by a formula:
Distance= (travel time/2) * 340m/s
340 m/s is the speed of sound.
##Infared Sensors Infared sensors function by shooting a beam of infared light, which is reflected back into the sensor. When the light returns, it hits the sensor at angle angle that depends on the distance of the object.