Photo interrupter with Arduino

In this project I use a transmissive photo interrupter to detect movement, count the movements and show the count result on a 7-segment display.

After pulling apart a printer some weeks ago I found many photo interrupters and I now want to test out how to use them with Arduino.

The type of photo interrupter I’m using is a three wire transmissive photo interrupters package, cosisting of a infrared (IR) LED and a photo transistor facing each other covered by plastic housing. There are many different types of transmissive photo interrupters, some have four wires coming out some have three, and the output connections may differ. I could not find an identifer mark on my photo interrupters and therefor couldn’t find a spesific datasheet for them. Analysing the circuit on the backside of the PCB I identified Vcc, Gnd and signal. I think the photo interrupter is similar to Omron EE-SX460-P1 (datasheet), but I’m alittle confused by the internal circuit diagram in the datasheet showing a resistor, which I cannot see on the actual photo interrupter PCB.

photo-interrupter-disassemblyIn my setup the IR LED in the photo interrupter is always on and the photo transistor allows a current to flow. When blocking the IR LED the photo transistor stops the flow of current and this is then detected by the arduino microcontroller.

The arduino circuit is simple. I added an LED to give a quick indication if the sensor was blocked or not. I based my arduino sketch on the State Change Detection tutorial. With this setup I also used the serial monitor to see the counting of state changes. photo-interrupter-diagram

Just for fun I also added a 7-segment display to show the count. In the code I used the same functionality as I used in the Arduino Pinball Targets project.

photo-interrupter-7-segment-display

The arduino code for the project can be found on github here.

I have allready been thinking about how I can use this in a pinball game setting and I think I’d make a “spinning target” or what I would call a spinning gate that adds score as it spins when the ball goes through.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s