Hi all, first post, so please be gentle. I've tried searching for a solution to my particular problem, but I'm not good at figuring out how to filter my results. My problem is such: theoretically, I am using an IR emitter and detector to create a True/False condition for whether or not an alert is triggered. As long as the IR detector senses emissions from the IR source, no alert is triggered. However, if the circuit is broken, the LCD should display a message and also have LEDs blink, as a visual alarm of sorts. This seems like a common enough scenario, but I haven't found any discussion or script to look at for guidance. Could anyone point me in a good direction for making this happen?
This reflectance sensor packs an IR emitter and detector in the same physical package, but it's functionally equivalent to using two discrete pieces. Scroll down a bit on the page for the schematic to see how the emitter and phototransistor would be wired up. The "out" pin will show a varying analog voltage depending on if something is blocking the light or not.
Be warned that IR phototransistors are sensitive to ambient light and it will not be practical to have a lot of distance between the emitter and phototransistor (a foot at best?). If you need more distance you can use a red laser pointer as the coherence of the beam will keep the phototransistor well saturated with light (the laser is "brighter" than expected ambient light). If you need even more reliability you can use a three-pin IR receiver, as would be used with a TV remote control, and send TV-like signals to the receiver. the IR library will help you with this. Doing things this way makes it impervious to ambient light -- it's a coded light beam, after all.
If you do use an IR emitter I suggest testing with a red LED so you can actually see what's happening. IR phototransistors/receivers are still plenty sensitive to red wavelengths.