Gadget freaks, model railroaders, roboticists or cat-hosts will love the versatility of the Sharp IS471 infrared proximity detector. It is the size of a transistor, operates over the 4-16 volt range, and can detect objects about 4-9 inches away by reflected IR pulses.
The basic implementation requires only the IS471, an IR LED and a 9 volt battery and can be built by most any tinkerer in less than 10 minutes.
Step 1: Gather the Parts
The parts you'll need are:
1) the Sharp IS471 (available for $2 at: http://www.junun.org/MarkIII/Info.jsp?item=46 or $3 from www.digikey.com, and others)
2) a 940nm IR emitter (such as the Fairchild QED-234, available from www.mouser.com for about 50 cents, and other sources)
3) Something to mount the above two items on. You've got a lot of options here. There are several excellent Instructables on making your own PCBs. If you want to try it out before doing the etching thing you can use a pluggable breadboard (not shown) or go with a small piece of perf-board (pads on .100" centers, shown at bottom left).
4) 9 volt batter and battery clip
5) Soldering iron & solder, diagonal cutters (if not going the breadboard route).
If you'd rather not etch, but still want something snazzy you might drop me a line about the very small custom perf-boards I had made at www.pad2pad.com (shown at bottom right), priced at $2 each for the bare boards, postage included).
Step 2: Putting It Together
Insert the leads of the IS471 into the perfboard close to an edge. The leads will need to be spread out just a bit, since they are spaced more narrowly than the average perfboard holes/pads. Note that the flat side of the IS471 needs to face outward, since this is the side that "sees".
Bend the IR LED to the right as shown below. With the LED positioned as shown the short lead (the cathode) is on top.
Step 3: Mount the IR LED
The LED is best mounted to the bottom of the perfboard as shown below. The board will act as a light barrier, so the IS471 will only see light that is reflected off objects rather than direct illumination from the IR LED, though you may need to add a strip of black tape when assembly is completed to prevent the IR pulses from shining through the holdes in the perfboard.
Position the IR LED so the short lead (cathode) of the IR LED is two holes behind pin 3 of the IS471, and the anode (long leg) of the LED is two holes behind pin 2 of the IS471.
DON'T MAKE ANY CONNECTIONS YET, THAT'S FOR THE NEXT STEP.
Step 4: Make Some Connections
Time to get the soldering iron hot!
1) Tack down all the pins of the IS471 and the IR LED just to keep them in place.
2) Connect the cathode (short leg) of the IR LED to pin 4 of the IS471 (just bend the leads together then solder to make this connection).
3) Connect the anode (long leg) of the IR LED to pin 1 of the IS471 (just bend the leads together then solder to make this connection).
4) Solder the red wire from the 9volt battery clip to the IS471 pin 1/IR LED anode connection.
5) Solder the black wire from the 9volt battery clip to pin 3 of the IS471.
6) Solder a wire to pin 2 of the IS471. This is the "Low on Detect" signal.
Step 5: Test It!
Now you get to test your new IR proximity detector!
Before snapping on a battery, check your work for solder bridges, there should be no connections other than those given in the previous step.
To test your proximity detector:
1) Connect the battery, then connect the leads from a volt-meter between the black (ground) wire of the battery clip and the "Low on Detect" wire.
2) Point the detector off into empty space and you should see about 8 volts on the meter. (Sometimes just laying it on a tabletop will allow enough reflection to trigger it, so you might have to raise it up just an inch or three).
3) Put your hand about a foot in front of the detector and slowly move it closer while watching the meter. Somewhere in the 4-9 inch range you will see the meter fallto 0 volts. You have been DETECTED!
NOTE: Location and placement is important. Sunshine will "blind" the receiver, greatly decreases detection range. I've found that just a little bit of a sun-shade takes care of this most of the time.
Step 6: Fun Time!
Just making a meter twitch isn't very flashy, especially to your non-geek friends.
How about triggering a Radio Shack 20 Second Record/Play module? This is good for adding sounds to a model train layout, or mysteriously playing the theme from "Twilight Zone" when you wave your hand over it? Or using it to automatically play a startling noise when triggered by your cat jumping onto your work-bench?
Step 7: Mysterious Sounds!
Connect your detector module to the circuit board of the Record/Play module according to the picture below.
Step 8: Controlling a Relay
For larger tasks you might want to use the proximity detector to control a relay.
I've used the circuit below and find it very versatile. You can hang several detectors off it and it will pull the relay if any of them see an object.
Step 9: Whatever You Want It to Do...
The open collector output of the IS471 makes it perfect for so many things it's hard to decide just which way to go.
Robot builders love it for non-contact obstacle detection, pet-owners can use it as a doorbell for their pet doors, model railroaders can trigger sounds or animations without reed-switches or track cuts... heck, I jsut like making things happen with a wave of my hands (just like in the sci-fi movies).