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!!!!!


Toranos (author)2015-10-17

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?


TimothyJ999 (author)Toranos2015-10-17

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.

andy_6 (author)TimothyJ9992016-11-01

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.

GaryC6 (author)2015-10-17

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.

pfred2 (author)2015-10-16

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.