Light Seeking Car (Moth Car)
Let me introduce you to my Moth Car! The Moth Car is made from the chassis of an old RC car I found out in the shed. Forgotten and deteriorating away I decided to give it a new life.
I carefully de-soldered the wires from the battery pack and DC motors and kept the receiver for another day. Using the Adafruit motor shield for the Arduino Uno I connected the cables. Making sure that everything was connected properly and operational I uploaded some test code and thankfully it all worked.
The next step was assembling the the photo-resistors onto the breadboard and then connecting them to the Arduino also, again I uploaded some test code to print the values of the photo-resistors to the serial monitor. Once the assembly was complete I took about working out how the car was going to respond to the light. In the first version of the code the car simply drove forward continuously and only the steering was affected by changes in light, in the first part of the video you can see this and also see how it kept trying to commit suicide on walls.
My mum saw the thing driving around into walls and asked if i could make it stop, replying with a no I thought why not? I plugged the car up to the computer again and brainstormed ideas how to control the acceleration. Looking at how the beam of a torch acted on the ground it occurred to me that I could use the difference between the photo-resistors to control the forward movement. It took more wall marking to find a suitable difference value but eventually it worked! If there is hardly any difference between the two photo-resistors the car will stop otherwise it will accelerate, this method of control was very effective with a torch indoors but not so much in pure sunlight. This version of the code is seen in the latter half of the video as it goes down the corridor.
I'm very happy with how it turned out and it works quite well! I took this out on our street at night and the car would gravitate towards the street lights. This light method of control is also much easier for younger kids to use and probably also more fun!