Accelerate : Flash / Arduino Based Speed Detector
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:
View HD version here.
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).
You can download the schematic from the project’s repository.
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 dont know enough about working on RC cars yet to actually take advantage of the data, but it is fun to hack around with regardless.
I have posted all of the Flash and Arduino code on GitHub, and released it under an open source MIT License. The AIR application is built using Flex 4, and although Flex 4 is not optimized for mobile, it performs really well on my Nexus One.
When looking at the Arduino code, keep in mind this is my first Arduino project, and the code could use some optimization, refactoring. (post in the comments if you have any suggestions).
I have posted some of the lessons learned from the projects in another blog post , so make sure to check that out.
Big thanks to Ben Griffith, Geoffrey Mattie who made some suggestions to clean up the design and UI of the app.
If you have any questions or suggestions about the project, just post them in the comments.
Update: Changed title since it is really more of a speed detector than speedometer.








very impressive, need to find time to play with this
Nikos
12 Aug 10 at 12:49 am
Nice work dude, I’ve been wanting to get my Arduino hooked up to Flash for a while now. Thanks for the inspiration!
Adam
12 Aug 10 at 8:43 am
Hehe, this looks like a lot of fun. Will order the components this weekend ^^
dietlev
12 Aug 10 at 8:46 am
eek, your poor camera haha Nice project Mike!
curtis dodd
12 Aug 10 at 8:46 am
How is the Arduino communicating with the mobile air app?
angel medrano
12 Aug 10 at 8:47 am
That is awesome! Cool post, Mike. I just picked up a package of photoresistors the other day, this could be a fun little project to play with.
Kevin
12 Aug 10 at 1:07 pm
Please post details on how you got the Adobe Air app on the Nexus One communicating wirelessly with Arduino. Are you using the laptop as an intermediary? Bluetooth? XBee? It’d be awesome if it was the Nexus One directly to Arduino!
Bill
13 Aug 10 at 6:28 am
How do you find time to release all these ideas? ….. actually it is even harder to find time to play with all these amazing gadgets :)
Michael Faure
13 Aug 10 at 9:02 am
love see cool stuff made with arduino and as3.
kevin
13 Aug 10 at 3:11 pm
@Bill
–
Please post details on how you got the Adobe Air app on the Nexus One communicating wirelessly with Arduino. Are you using the laptop as an intermediary? Bluetooth? XBee? It’d be awesome if it was the Nexus One directly to Arduino!
–
The arduino is connected to the mac via USB / serial. On the mac is a serial to tcp socket proxy (tinkerproxy). The Mac creates a local wifi network, which the Nexus One connects to. The app on the nexus one then connects directly to tinkerproxy running on the mac.
Once tablets come out, I suspect that we will have access to a USB port, which means we could use the xbee wireless stuff and have the android device connect directly to the arduino wirelessly.
Hope that helps…
mike chambers
mesh@adobe.com
mikechambers
13 Aug 10 at 6:01 pm
How about throwing an 2-way X10 interface in for some home automation?
Ryan P
14 Aug 10 at 9:56 am
I think the Adobe AIR part is the best… the actual speed monitor is too slowly polled to be useful for fast RC cars… i.e., it won’t be very accurate if something goes between your sensors at say 60mph. At those high speeds it will likely be able 20% off.
Brett
14 Aug 10 at 11:17 pm
@Brett
–
it won’t be very accurate if something goes between your sensors at say 60mph.
–
Yeah. The code can be tweaked to handle that speed. You just need to keep track of the changes in the light sensor over more intervals (sub ms refresh), and then look over the data set to see when it began to change.
A little more complicated, but completely doable.
mike
mikechambers
15 Aug 10 at 12:02 pm
It looks like within few years we will all be able to create our own devices or robots and program them… like in any science fiction book/movie…
haha cool stuff and congrats ^^
Baz
17 Aug 10 at 8:04 pm
@mikechambers not sure if you’d come across this http://www.amarino-toolkit.net/. You’d just need a bluetooth module/shield on the arduino. Haven’t tried it myself since I don’t have an Android device to test with.
kevin
18 Aug 10 at 12:41 pm
hi mike,
thanks for the article.
AIR with arduino rocks..i have developed a wireless chemical board for our UAV. all data came wireless over 868mhz arduino board to an AIR interface. i use a small serial proxy driver. i showed our customer in less then 2 days a working version. we interprete all data in AIR and send it via a 3G stick to a fire department which is located over 2000 kilometers.
next thing is to capture a videoraw feed and send it with the sensor data over rtmp to an level(3) CDN.
here is the uav with our board:
http://rebotnix.com/index.php/f8oche.html
and here you see a first version of our AIR sensor GUI
http://rebotnix.com/images/humidty.jpg
when you have a chance to bring new things to AIR, please tell the AIR developers if its possible we can listen directly to the serial bus.
and if i have another wish..you have so much good contacts to nvidia..please think about to implement cuda support to flash and AIR/AS3. when we can render data and bitmaps to cuda with as3 language then a lot of dreams come through. i know abdobe will support all plattforms, but why to detect if a cuda driver is installed and then switch from cpu to gpu or to both?
thanks…
gary
gary
23 Oct 10 at 5:21 am
Hello Mike does AIR 2.5 supports data from USB ??? How can you read data ?
Valery
18 Jan 11 at 12:56 pm