Well, I like to write up Instructables that (hopefully) make it easy to get started using different sensors and misc. components. But in this case it doesn't get much easier right out of the box. This infrared sensor, sorry "switch", is basically plug-and-play. Apply the appropriate power and ground to the switch and it starts doing its job.
However, I do find it a little quirky that the Signal wire (yellow) on the switch is normally open (N/O). Meaning there is voltage on the signal wire before the switch detects anything. And when it does detect something it pulls the signal wire LOW (no voltage) until whatever it detected has moved on. I think we're more used to a wire or pin going HIGH (being supplied with voltage) when (X) happens, not the other way around.
I don't know, it's just backwards in my head.
Even though this switch has a built-in LED that indicates when the switch has been tripped, it's a simple setup to play with an external LED. So why not?...
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: LED Play Time
There is no code accompanying this because we don't need any. The Arduino board will only be used to supply power to the switch (5v).
(remember to remove power from your Arduino and/or breadboard before hooking things up)
1. connect 5v out from Arduino to 5v in on switch (red wire)
2. connect GND from Arduino to GND on switch (green wire)
3. connect Signal wire (Yellow) to positive leg of LED
4. connect negative (GND) leg of LED to Arduino GND
I didn't bother with a resistor because the specs tell us the Load Current is 100mA and yeah technically I should throw about a 10 Ohm resistor between the Signal wire and the LED but I'm an adventurer and going without it.
At this point you can power up your Arduino and the LED should be ON until you interrupt the "beam" from the switch.
Step 2: Switch Specs.
Operating Voltage: 5v (couldn't locate a min or max Vin)
Operating Current: 10 - 15 mA
Output Current: 100 mA (low enough not to worry about a resistor if you wanna play with an LED)
Range: 3 - 80 cm which for us non-metric Americans is 1 - 31 inches (ok, I rounded - a little)
Note: The range is adjustable via a small screw on the back (bottom) of the switch. That "screw"' would actually be turning a potentiometer (or POT as they're known). A POT is basically an adjustable resistor, turn it one way to increase the resistance, turn it the other way to decrease the resistance.
Response Time: <2 ms
Operating Temperature: -21'C to 55'C which for us non-metric Americans is really freak'n cold to very (left blank intentionally) hot
I thought the "Range" was a little wimpy until I took into account that this is marketed as a "switch", not as a sensor or something else I'd expect more range from. I'm sure I'll find plenty of opportunities to use this switch. It works, it's easy to set up and it's conveniently packaged (the case is threaded and comes with two retaining nuts).
Thanks for reading and as always if you noted any errors or omissions please do not be shy, leave a comment or drop me a note.