Adding an Opto-Interruptor Part 3

As I’ve already discussed here and here, opto detectors are one way to sense position. Unlike a switch, there’s no moving parts, so reliability is high. However, the compromise is a more complicated setup.

In a previous article, I showed a schematic that sent a signal to the Arduino when the light beam was unbroken between diode and sensor, and turned off when it was broken. One reader commented that the usual way was the reverse, and included a link to a schematic. The result? Two resistors instead of three, and a simple wiring job to add photo detection to the Arduino.

The devices I’m using are the HY306-02 photoelectric sensors, which I got on eBay for under 75 cents each (in packs of 10, of course), but any optical (photoelectric) sensors on eBay should work. The procedure is simple: an infrared diode shines into a detector, and both are held in place by a plastic casing (which also provides the gap between them, and the thin slit to let light pass).

Showing the glue, heat tubing, and solder - a compact mess!

Using this new circuit, the device is pretty simple to get going. One caveat: although the layout looks nice and neat here, in fact the device has reversed leads from the schematic (I reversed the detector leads on the diagram so the schematic wouldn’t look so messy with crossover leads). This means you’ll need to wire one resistor crossing over the other. In my case, I first filled the void with hot glue from a glue gun to keep the bare leads in place (apart). I then twisted on the two resistors, using a shrink heat tube to physically space the wires from each other. Finally, I soldered it all up.

The result is a nice tight bundle ready to go into the Braille device. Three wires come out of it: ground, power, and the Arduino detection wire (which can go to any digital pin). The signal is reversed (the Arduino detects a HIGH on the pin when the light beam is interrupted), but that’s a small price to pay for a circuit that is compact and easy to put together.

Finished device with wiring

While a switch is much simpler to wire, this opto circuit has one benefit (besides no wear of course) – it can be used easily for left and right detection of end stops. In my current design, it sits below the motor, perpendicular to travel. At each end of travel, I have a small flap of material to block the light – the result is it can detect left and right end without a second switch or sensor.

Although a bit tricky to use, optos like this are very handy for devices that need high reliability. For future use, I may consider just soldering four wires to it, and then bringing them out and wiring the resistors where there’s more room – however, for now it works, and that’s the main thing!

Ricoh copier AW020203 photo interrupter sensor 200/250/1022/1027/5500/6500/7500
End Date: Monday Mar-19-2018 13:16:50 PDT
Buy It Now for only: $13.99
Buy It Now | Add to watch list
hy870p 1/8" gap photo interrupter slotted optical switch, 10 pieces with
End Date: Saturday Mar-17-2018 1:00:26 PDT
Buy It Now for only: $16.48
Buy It Now | Add to watch list
photo-interrupter sensor module for arduino and raspberry pi
End Date: Saturday Mar-17-2018 0:28:39 PDT
Buy It Now for only: $8.51
Buy It Now | Add to watch list

3 thoughts on “Adding an Opto-Interruptor Part 3

  1. This is a great article. I am trying to get a digital signal from a computer mouse’s scroll wheel. What’s different (and can’t find anywhere) is that the phototransistor is a dual style. Meaning that I have an IR LED pointed at a small black box inside of which are 2 phototransistors. The catch is that this black box only has 3 wires connected to it. Channel A, 5VDC, Channel B. I had data (1’s & 0’s) working with Channel A going to my Arduino Uno. However, when I connect Channel B, both show the same data, and they are suppose to be offsync by 90degrees. I also have to use a 1MegOhm resistor to get it to work. 10K just shows all 0’s. Any thoughts on why the data matches? and why I have to use such a high resistance? Thanks

    • I think the problem is that it’s the outside input has to be 90 degrees out of sync – internally, the device just sees on and off. Check the mouse for a two-pattern disk or reflector, with each positioned for a different sensor.

Leave a Reply to Steven Cancel reply

Your email address will not be published. Required fields are marked *