Ever looked on Sparkfun or Adafruit for some cool robot parts, and saw those expensive IR and Ultrasonic proximity sensors? I have, and I really wanted one, but they're so expensive ($30-$40 or more) so I decided that I could make one myself with the parts I had on hand for way less.
What I came up with was an infrared distance/proximity sensor that sensed an object up to about 10-12 inches away all for about $3.
It is fully compatible with Arduino and other microcontrollers such as PIC, PICAXE, and Parallax Propeller (although the code would have to be different than the Arduino code I will be showing you).
Step 1: How does it work?
The way this sensor works is like this.
1. An IR (infrared) LED emits a pulse of light at the rate of 38KHz. The pulsing rate of the LED is controlled by an Arduino's PWM output.
2. An IR Receiver module is connected to a digital pin on the same Arduino. This module can detect a IR light signal that is pulsing at 38KHz, which is the speed that led Infrared LED next to it is flashing.
3. If there is an object in front of the IR LED and the receiver, the object reflects some of the light back onto the receiver. The receiver detects this light and sends information back to the Arduino.
4. If the receiver detects an object, it sends LOW to the Arduino's digital input. If it does not detect anything, it sends HIGH.
5. The Arduino then processes this and uses it to control a device of your choosing. It can be anything from an LED to a servo motor to a solenoid.