Here are a couple of pictures of the breadboard setup:
The first picture is of the breadboard itself. The components are marked and the green dots are where the wires from the photointerrupter go.
The second pictures includes the photo interrupter mounted to the barrel using duct tape (what else). Note that this was before the Max7219 and display was mounted:
For the Airsoft Round Counter project I need some way of detecting when a round is fired and (like most people suggest) a photo interrupter is ideal for the purpose.
Basically, a photo interrupter consists of an LED (usually an IR one) and a photo transistor. A photo transistor works like a normal transistor but instead of a current at the base, it requires light to turn on the collector-emitter current flow. In a photo interrupter the LED and the photo transistor are mounted in small posts and when nothing interrupts the beam, the transistor turns on, passing a current from the collector to the emitter. When the beam is interrupted, the transistor turns off.
A photo interrupter has four leads or connectors: anode and cathode for the LED and collector and emitter for the photo transistor.
To use it in as a digital input for a microprocessor, you can create a circuit like this:
R1 limits the current to the LED (using the normal LED calculations having obtained information about the LED forward voltage and desired current from the datasheet – typically something like 2.0V and 20 mA).
When the photo interrupter is not interrupted, the input reads 0. When an object blocks the beam, the input reads 1.
This document from Lite-On has some excellent information about using photo interrupters (after the list of their products).