Slotted Optical Switch

DVDdoug:

You need a current-limiting resistor in series with power to the LED (not shown on the 4n25 datasheet), and you need a pull-up resistor on the output transistor. Assuming the thing is running off the Arduino's 5V power supply, a 150 Ohm resistor in series with the LED will give you a little more than 20mA. The the pull-up resistor value is not critical at all (because of the Arduino's very-high input impedance) and the easiest thing to do is to configure the Arduino's [u]Internal Pull-Up Resistor[/u].

I'll try this :slight_smile: