Why are the photo interrupter not working?

Hi Everyone,

I am an electronics newbie and so please pardon my dumb question.

I have been playing around with this photo interrupter: http://www.mouser.com/ProductDetail/ROHM-Semiconductor/RPI-246/?qs=sGAEpiMZZMuIaPd8bG7xI%252bl9upIhrRZ5UM1vwiGgRC0%3d DataSheet: http://www.rohm.com/products/databook/s/pdf/rpi-246.pdf and to my surprise, none of the circuits that I have come across are working.

I tried the following: 1. http://capolight.wordpress.com/2010/11/24/making-endstops-from-printer-photo-interrupters/ 2. Tried the circuit in the datasheet


I finally tried this pin out: Pins 1&2 are the LED: Pin 1 goes to one end of a 120 ohm resistor, the other end of the resistor goes to +5 volts. Pin 2 goes to ground. Pins 3 & 4 are the photodetector Pin 3 goes to the Arduino digital input pin, this should be treated as if it was a switch Pin 4 goes to ground.

I then put in a 10K resistor between 4 & gnd and that too doesn't seem to work.

void setup() 
    pinMode(2, INPUT);  

void loop() 
     int p=digitalRead(2);

Is there something that I am missing? Can someone please provide me the pinout... I guess I can try different things out once I get the basic circuit up and running.



A reasonable assumption, but I can't verify from the data sheet.

Pin 1 goes to one end of a 120 ohm resistor, the other end of the resistor goes to +5 volts. Pin 2 goes to ground.

Other way around. Pin 1 to GND, 2 to 5v. Resistor can be in series on either side of the LED.

10K resistor between 4 & gnd

You can do this two ways, the link you showed has the resistor from pin 4 to GND, the Arduino input on pin 4 and pin 3 to 5V.


Pin 3 to 5v (through a resistor) and have the Arduino input on pin 3.

One way will invert the signal, the other will not.


The data sheet is quite unclear to me as to the pinout re long/short leads. It's quite possible the long lead is the cathode.

To find out do this.


Now measure the voltage from long pin to short pin.

If the LED is conducting it will have about 1.5v across it so the reading will be something in this range. long pin = Anode, short pin = cathode.

If the LED is not conducting it will have 5v across it. short pin = Anode, long pin = cathode.


Thanks for the advice. It looks like I was dealing with two issues: 1. The datasheet is wrong. The long lead is the anode. Pin 2 and Pin1 in the datasheet are actually Pin1 (Long lead: anode) and Pin2 (cathode). 2. I destroyed quite a few photointerrupters during my initial "tests"; of course, I never realized that they got messed up. This compounded the problem.

In anycase, I got the photointerrupter working. This part is pretty good. Its quite responsive and works like a charm.

Thanks again....