Measuring distance/proximity
If you need to quantify distance:
SHARP 2Y0A02, IR sensor (λ = 850 ± 70nm)
At-a-glance useful details:
- Sensing range: 20 - 150 cm
- Power requirements: 4.5 - 5.5 V (typ current consumption = 33mA)
-
link to datasheet
- Output voltage is not linear with distance; see plot below (from datasheet, linked above)
Ultrasonic Sensor (HC-SR04)
These sensors can detect objects within a range of 2 cm - 4 m with a ranging accuracy of up to 3mm. One thing to note is that they have a measure angle of 15 degrees, so they do well at measuring objects directly in front of the sensor. For most applications, this is favorable.
Helpful resource from Sparkfun with example code, and wiring diagram: https://www.sparkfun.com/ultrasonic-distance-sensor-hc-sr04.html
If you just need to know if an object is present or not:
(e.g., detecting fan speed, motion detector, etc.)
Hall Sensor (AH1815, from Treston)