I got some very interesting and wonderful presents this Christmas (thanks Mom, Dad, and Father-in-Law!). So... what can you make with a microcontroller, a Wiimote, and a laser? More on that another time, if I can pull it off. But here's how you can run a Wiimote IR camera with an mbed and track a laser dot (or other light sources) on your Windows, Mac, or Linux host.
Meanwhile, my parents very generously gave me an mbed microcontroller -- a powerful ARM Cortex M3 on a 40-dip board. Thanks Mom and Dad!! You can see it hooked up in its first, post-"hello world" experiment.
The Wiimote I planned to hack was purchased with a most generous gift card from my father in law (thanks, Mike!) Inside the Wiimote is an infrared camera that tracks infrared light point sources and reports their coordinates over I²C.
I'm following in the footsteps of great hackers, here. Here are the sources for the Wiimote IR Camera hacks:
After disassembling the Wiimote, I desoldered the camera using solder braid with some extra flux paste. I soldered the camera's 8 thin leads onto a 2x4 pin header and soldered that onto a perfboard with 1x4 headers on either side so I could easily breadboard the thing.
Wiring the Camera to the mbed
Using the mbed, the interfacing is super simple.
The LPC1768 is a 3.3V device, eliminating all the voltage level translation hassle that the 5V Arduino owners had to endure.
And, since it's running at 96MHz, programmed one of the mbed's PWM signals to output an ~20MHz clock signal for the camera. No crystal oscillator necessary.
The camera pinout is shown in the image below.
Here's a quick and dirty schematic. Note the pullup resistors on SCL, SDA, and RESET. In kako's and others' schematics, there's a 0.1uF capacitor between RESET and GND, probably to filter glitches. So far I've gotten away with omitting the cap.
|Wiimote to mbed wiring schematic. Click for large version.|
I converted kako's source code to mbed C++ and added the ~20MHz clock signal on p21, and setup I2C communication on p9/p10. The source code listing can be found here.
Here some sample output over the USB serial device while the camera tracks a laser. The camera tracks four light sources and provides x and y coordinates. The output from the microcontroller is a comma-separated list of x-y pairs: x1,y1,x2,y2,x3,y3,x4,y4
239,272,360,299,1023,1023,1023,1023 235,267,353,292,1023,1023,1023,1023 237,274,359,300,1023,1023,1023,1023 251,284,368,305,1023,1023,1023,1023 253,292,375,319,1023,1023,1023,1023 253,298,374,322,1023,1023,1023,1023 256,299,376,322,1023,1023,1023,1023 258,299,376,319,1023,1023,1023,1023 ...
PC GUI Client Software
I wanted to visually display the camera's tracking data, so I wrote a Java Swing equivalent of the CC2's ATM 18 Project BlobTracker Front End software, since I couldn't get it to work. Well, the Java app works pretty well. Here is the source code for the Java app.
I mentioned the laser and used it here, but I have other plans. I'm still working on it. If I pull it off I'll be sure to post.
Happy New Year!