Step 3: IR Detector Circuit
IR Detector Circuit
I figured the easiest way to detect breaks in the light path was to use an IR LED and IR phototransistor, configured so that the phototransistor is either "on" or "off" instead of using a photocell with an analog threshold.
I found the configuration in the Forrest Mims circuit notebook "Optoelectronic Circuits" - the excerpt is in the images below. These books are wonderful, by the way. I'm anxious to try many of the other sensors and circuits he describes in them with the Arduino.
A 10K Ohm resistor goes from the +5V connector on the Arduino to the collector on the phototransistor (pin 2). The emitter of the phototransistor (pin 1) is connected to ground (again on the Arduino board). Pin 3 is unused and can be bent out of the way or clipped. The collector (pin 2) is also connected to the digital pin 2 on the Arduino. Input 2 on the Arduino corresponds to interrupt 0, which we will be using to count pulses.
I used alligator clip patch wires to connect the phototransistor and small angled pins on the breadboard to connect to the circuit. The hookups for this project are simple enough that you could probably do point-to-board wiring and just plug the hookup wires into the sockets on the Arduino. I used a small breadboard instead. Of course, if you have the Arduino shield, construction would be even easier.
IR LED Circuit
The Arduino Diecimila has a current limiting resistor on pin 13, so to reduce the parts count, I connected the IR LED to that pin. If you have an older Arduino board, remember to connect an appropriate series resistor to the output pin. The connections for this were also done with a right-angled header on the breadboard and alligator clip patch wires to the LED. Anode to digital pin 13, cathode (flat side) to ground.
Since we're dealing with invisible IR light, interrupts, and serial communications for status, I wanted to see something that would tell me the circuit is working, so I connected a RED status LED to digital pin 12 through a 220 Ohm series resistor.