wiring up a beam break sensor?

Hi - I got a couple of linear peristaltic pumps on ebay. (absurdly cool cam action). I have the stepper motor running so that's good. Now I want to read the beam break encoder (on right side in photo - a bit hard to see)

I know this is dead simple but I don't want to chance shorting it out, so I thought I would ask.

There are four wires total:
--Red/Black on one side of the 'U' (the LED I suppose)
--Green/White on the other side.

I am assuming R/B is +5 v/gnd and I should add a resistor
For G/W - I would hook one of them to a digital input pin and hook the other to gnd. Then read the state of the pin either through polling or through an interrupt.

Does that sound about right?



Red+black as the LED is a decent assumption. Try applying 5V through a resistor (330 ohms) and you should measure a small current flowing (~10mA give or take 50%). If not, reverse red and black and try again. If still nothing, maybe the green+white are the LED?

For the LED (assuming green+white), you are correct that you should hook one of them up to a digital input and the other to GND, but you will also need to enable the pullup resistor on the digital input.