I've had my Arduino for a few days now and have done the obligatory "blink" tutorials. But now I've created my first semi-useful project: A LIGHT CONTROLLED CAR.
For US$2 I purchased a remote controlled car from a garage sale. It was missing the remote control, but that didn't matter because it was goint to be Arduino powered!
STEP 1: How to control the car? After some circuit-bending, I figured out where a simple jumper would turn on the drive motor. Next, I soldered a lead on each side of the junction so that when I connected the leads, the motor would turn on.
STEP 2: Use Arduino as a switch I didn't want to overload my Arduino, which only produces 40ma per pin. So I used an ammeter to measure the current draw by the toy car motor: 500ma w/ no resistance, and over 1A with resistance on the wheels (such as when the car would hit the wall with it's motor still on). Unfortunately, my only transistor could handle a max of 500ma. So I needed something a little beefier. After looking online for some circuits, I decided on a TIP120 Darlington NPN transistor.
First, I hooked a digitalPin to a 1K ohm resistor and connected the resistor to the base of the TIP120. Then I connected the emitter of the TIP120 to ground. Next I connected the postive lead from the toy car motor (utilizing it's built-in batteries as a power source) to the collector. Finally, I connected the negative lead from the toy car motor to the emitter.
Time for some code...so I wrote a quick test program to turn on the motor for 1/2 second and turn it off for 5 seconds.
It didn't work! After some investigating, I discovered that I had accidentally used a 10K ohm resistor in series with the transistor instead of a 1K ohm one. So, I subsituted the correct one. Now I was ready.
It didn't work! I tried (almost) everything. I wasn't getting the current flow from the transistor that I expected. However, the transistor did seem to be switching properly. I was about to declare the transistor as bad when I remembered that I had not delared the digitalPin as an OUTPUT! I made the change and uploded the sketch again.
STEP 3: Control it with light OK. Now to make it a little more nifty. I hooked a photocell to +5 and the other side to an analogPin. I then used a 10K ohm resistor as a pull-down resistor between Gnd and the side of the photocell connected to the analogPin.
Next, I needed to calibrate the sensor. So I wrote a quick sketch to echo back the value from analogRead to the serial port. Then I ran the sketch and looked at the output in the Serial Monitor to decide on a threshold value.
Lastly, I created a sketch to turn on the motor when ever the light value went above the threshold value.
Now, when I shine a flashlight on the car...it goes! And when I take it away, it stops. Pretty stupid cool.
Code (and possibly photos) to come.