Accelerate : Flash / Arduino Based Speed Detector

Wednesday, August 11, 2010

Well, as you may have noticed from my blog posts the past week or two, I have been playing around with Flash and Arduino. I have a ton of ideas and projects in mind, but wanted to start on something that wouldn't be too overwhelming, and would give me a good opportunity to learn the basics. Well, I have finished my first project, and wanted to share it with everyone. It is a Flash / Arduino based speed detector with clients for Mac, Windows and Android based devices (via Adobe AIR 2.5 beta).

I have put together a quick video that shows the app in action:
<!--more-->

Here is how it works. I have an Arduino Duemilanove with ATMega328 which has two photo-resistors connected (with a 10k pull down resistor). I set up two laser pointers to shine a laser directly onto the photo-resistor (which is enclosed within a dark box). The Arduino monitors the values returned from the light sensor, and watches for any changes that indicate that the laser bean has been broken. When both laser beams are broken, the Arduino calculates the amount of time between when each sensor was tripped. It then sends that value to the Adobe AIR based client, which is connected to the Arduino via USB / Serial port and a serial port proxy (in the case, TinkerProxy).

Once the AIR application (running on the desktop, or an Android based device) gets the message from the Arduino that both sensors have been tripped, the AIR app takes the time that it took for each sensor to be tripped, and combines it with the distance between the sensors (in inches), and uses that data to determine the speed.

While I put this together mostly for fun, it is actually useful for tweaking RC car gears and setup. You can use it to help tweak both maximum speed, as well as acceleration / starting speed. Unfortunately, I don't know enough about working on RC cars yet to actually take advantage of the data, but it is fun to hack around with regardless.