Saturday, April 19, 2008

Happy Microcontroller Birthday!

This year for my birthday I asked for a make controller to carry out my dastardly little science experiments with.
A microcontroller is basically a tiny computer that you hook up to motors and sensors and stuff.
Anyway, this microcontroller can be fit with wireless modules called Xbees. That means you can hook sensors, switches, buttons, etcetera up to the wireless module, and have your movements get sent back to the controller so it takes action.
I decided that my first project would be hooking up my new microcontroller up to my RC car. That would allow me to get... not only normal car movements... but also I could hook up some James Bond type gadgets to the car and control them too.

I started off by "repurposing" an old USB wavebird joypad for my PC. I opened it up and tapped into all the button and control stick signals and fed them in to the Xbee module as shown below

So now all of my button presses get sent back to the microcontroller which is mounted on the car. The sweet thing about the Xbees is that they have a 1 mile range. So I can control the car from way far away.

The next step was to attach the microcontroller to the car and then program it. I had to write a program in C++ that would tell the car what to do for each button I pressed, whether it is to listen to a sensor, make the wheels go, turn lights on, etc. The program is basically the most important part, because it determines how your car will act, if it will be autonomous, or respond to user stimulus, etc.
So I have one Xbee hooked up to my new joypad, and also one hooked onto the microcontroller on the car, so the car will hear what my joypad is doing and take action.
I hooked up the steering and drive wheels to the servo outputs on the microcontroller (above right).
I then made some headlights out of superbright LEDs and mounted them like fog lights. I also decided that any self-respecting RC car needed a horn so that you could annoy people. Naturally I would have to add one.

So then I wrote my program up and after a few attempts, got the car to start responding. So now I've got to decide what else I'll put on the car. I think i'll put a little light sensor on and maybe some running lights that will turn on when it gets dark.

I'll probably also make a little airsoft cannon that i can aim with servos and hook that up too.
A wireless camera might be a nice addition.

Any other ideas?

I guess that engineering degree was good for something after all..


Alex & Anna Winn said...

And I thought Alex was sick - Anna

sean said...

Hey, did you have to do anything to program the Xbee?


Aaron Tunell said...

well, you have to tell the xbee what mode to work in serial or sensor, and then you have to tell it which pins to listen to, it may also be necessary to update the firmware too.