Mostly for the Science Olympiad – Division C – Maglev event, but also just to learn more about Arduino in general, I tried to build a photogate setup on the cheap;-) I expect the Maglev event’s timed part to be somewhere in between two and three seconds. So even for test runs, a hand based stop watch is not really an option.  Some high schools apparently have photogate timers for their Physics education (we had them even at the middle school level in Germany around 1982), but our charter school does not. So those are basically the reasons why I set out to build something to use.

After looking at the commercially available setups and finding that they are somewhat out of what I wanted to spend, I found Liudr’s Photopage which gave  me hope. He used rather small gates which would not work for me. So the first step was to find some gates which could handle >= 8cm distance. I found that the Honeywell HOA 6299 gates should be able to do that and that it should be really easy to interface them to the Arduino ports;-) I got two pairs @ for $63, not exactly cheap but cheaper than one complete commercial gate.  They work very well with my Mega ADK;-) I currently use a breadboard, but it is not really needed. The 5V pin works well as power supply for the gates, and the outputs go straight to pin 2  and 3 respectively.  Any 5V based Arduino should be able to handle the gates, the ADK is kind of overkill for this, but that’s what I have;-)

For the software, there are two parts. The Arduino sketch gets interrupts from the two gates and basically takes it’s internal time and sends lines over the USB/serial connection to the computer which acts as display and interim time source. The Arduino does not care what will be done with the events, it just sends one line with three parts separated by colons. The gate number ( 1 or 2), the time in milliseconds since the start of the board and the microseconds within the current millisecond. Lines look something like


That makes it really easy to do different things depending on what you want to do. My little sketch PhotoGates.ino is here, if somebody wants to play with similar things;-)

For the stopwatch/display on the computer (I prefer Linux;-), I Frankenstein’ed the dclock sources, to do what I want;-) That was the best source which would work well in different sizes, I updated it to show three digits for the milliseconds 😉  Right now that piece is really raw!! But it takes the lines from the USB/Serial port (Watch out, I don’t think the option to change the port actually works yet!!) and handles them correctly. When it sees a line from gate one, it stores the time values  and starts a clock from null  on the computer to show a moving time until a line from gate two arrives. When the line from gate two is handled, the difference between that and the save time from gate one is pushed to the display.  So no matter how long the events take to get to the destination or how busy the computer is, the time should be correct in the end;-) My sources are here dclock-2.2.2-mw.tar, but they might still need some improvements. For other OSs, I don’t know but something similar should be possible as well. But I prefer Linux;-)

Right now, I have the two gates right behind each other, something like 7 cm apart. That’s just for now for easy testing;-) The fastest I could cover that distance with a pencil or a kebab stick (1/8″ dowel;-) in my hand, was 0.014 seonds;-) That’s about 18kph/11 mph.  But that just my slow hand;-)

So far, I’m pretty happy with the setup. It should definitely be able to do what I wanted it for. If somebody wants to play with similar stuff of has a question about it, real comments are always welcome;-)

As always, have fun playing with things in new ways;-)

Update: The Complete Track and Timer is here;-)