How to Use Photo Interrupters With Your ARDUINO




Introduction: How to Use Photo Interrupters With Your ARDUINO

A photo interrupter is a devise that is made up of a infrared led and a photo transistor with a gap between the two of them, When something is placed between the gap the light is cut and the current flow through the photo transistor is reduced or stopped. The picture above shows three photo interrupters, the first two are salvaged from old printers and the third is a HY810H that I got on ebay (10 of them for under $5)...

In this instructable I will show you how to use one to trigger a tone alarm to go off when something is placed in the photo interrupters gap, This circuit can easily be modified to trigger many things if the light is interrupted..

Step 1: Build the Circuit.


1 X 560Ω resistor.

1 X 56KΩ resistor.

1 x piezo or small speaker.

1 X photo interrupter (I used a HY810H I got from ebay).

ARDUINO board, bread board & jumper wires....

The picture above shows the simple circuit you will need to build.

The 560Ω resistor connected to the IR led is to cut the arduinos voltage from 5V to about 1V, The HY810H IR led input max voltage is 1.6V and the 560Ω resistor brings the arduinos 5V supplied voltage down to 1.17V (well below the tolerance but high enough to get good readings from the photo transistors output).

The 56KΩ resistor is connected to the photo transistor to work as a voltage divider to get your analog reading to your arduino board, I tried this circuit without the voltage divider and it would not work worth a crap. When I set it up as a voltage divider I got very good and stable readings to the arduino board!

The rest of the circuit is pretty self explanatory so lets move on to testing it out..........

Step 2: Loading the Code on Your ARDUINO

Now that you have the circuit built lets load up some code and try it out.

Just copy and past the code below into your ARDUINO ide and up load it to your ARDUINO.

int val;
void setup() {
void loop() {
val = analogRead(A0);
if (val<=200)

Now that you got the code uploaded lets move on to testing it out!!!

Step 3: Testing It Out.

Now that you got the code uploaded and running open up your serial monitor (just to monitor the analog input for tweaking the program) and find something to put in the photo interrupters gap to set the alarm off. If you are using a different photo interrupter you may need to modify the code to work optimal for you, but if your using the same stuff as me just put a piece of paper between the gap and the alarm should go off...

If you have any problems or have a question please leave a comment below!!!!!

Be the First to Share


    • Reclaimed Materials Contest

      Reclaimed Materials Contest
    • Made with Math Contest

      Made with Math Contest
    • Paint Challenge

      Paint Challenge



    1 year ago

    the 56k isnt a divider, its an emitter follower configured pull DOWN.
    for 5v, 1K will suffice.
    can just as easily be stuck on top for collector follower pull UP. reversed logic.

    far better to set up your interrupters backwards. ie, keep them blocked and use the clearing to trigger your device. just a little pinhole in a strip of metal is enough. why?

    check the data sheets regards the phototransistors turn on vs turn off times. ;) some circuits might require that speed factor. like high speed rotary encoders or data transmission.

    i think collector follower turns off slightly faster as well as it gives the transistors gate a lower impedance path to ground. the only thing that turns them off is the discharge of the gate capacitance. your 56k will be slowing it down dramatically. great gain, lousy switching. ie, if you applied an audio signal to the LED it would transmit through, but you arent driving the transistor to saturation to get good switching/square wave/risetime/hysteresis/you name it

    John Bond
    John Bond

    3 years ago

    Thanks for this clear and educational instructable.

    It's sad that a 555 has been suggested in the comments.

    1. Your project is MUCH more flexible. For example a second 555 (or a 556) is needed to drive a piezo.
    2. You are able get twice as many pulses than there are slots by reading the rising and the falling signal. By fitting a 2nd sensor on one of the available I/O and offset it by half the gap width, you can also read the direction of the movement. If you add more sensors and use a grey code strip/disk. You can get position. For example using 5 sensors, you could know the exact position to within 12°.
    3. If cost is a problem, use the Arduino compatable AtTiny85 with 4 or 6 I/O. This is 3 more I/O than the 555 and provides big additional benefits. You have timers, logic, state etc. The AtTiny85 cost under US$2.00, hardly more than a handful of 555s (which the project will need) and a 3rd of the effort.

    Thanks again and well done


    6 years ago

    I looking at using them to turn on something when some walks through them. Do you know what the max distance between emitter and receiver can be?
    Or what would I need to have approx 1m max distance? I would guess I need to use an array of ir emitters to create a large enough output... But how many?



    Reply 6 years ago

    A photo interrupter probably isn't the best thing to use for large gaps like you describe--there's too much interference coming from ambient light to get a reliable response.

    One alternative would be an Arduino-compatible PIR motion detector; another would be an infrared laser transmitter, aimed at a photodetector.

    Either one is available on EBay for under $5, and would be a much cleaner solution.


    Reply 5 years ago

    The photo-transistor in these things usually has a visible light blocking filter painted on it. The LED is usually IR, so no problems with ambient light.

    It is the best economical solution considering it costs pennies.


    6 years ago

    This is not intended as a criticism but, a 555 can do the same thing cheaper. Unless you are controlling something more an UNO is overkill. Just another way.


    6 years ago

    I was fooling around with parts I pulled out of one of these photo interrupters a while ago. I never got as far as hooking it up to an Arduino yet myself. The signal that comes out of the photo transistor is so ugly I worked on trying to clean it up somewhat first. I think I made a Schmitt trigger out of an op amp, or something. It still was not going to ground quite as hard as I'd like to see it do though. That was where I left it. I'll get back to it one of these days. Right now I'm working on something else.