Introduction: Light Seeking R.C Car Hack (with Arduino)
Creating a robotics platform from scratch takes allot of work and a few dollars. Buying a ready built one is easy but costs allot of money (at least for me). So instead I decided to piggy back off of the companies who make remote control cars.
This is a great because it comes ready made with two h-bridges and a steering mechanism already built. The cost of the whole project is probably $90 if you don’t have any of the materials but for me I was about $3(for the batteries).
This test shows how the robot works. I didn't have a large enough space to test it while it moved. And I also had it running the dark seeking sketch.
Because i'm entering this in the robot contest I'd like to say i'm 13-18 years old and belong to the 401 venture company (scouts).
Step 1: Materials
Materials:
1x Arduino (I used an Uno but any will do)
1 x Breadboard
1 x 9v Battery
1 x 9v to Arduino cable (link to make your own)
1 x Arduino to USB cable
1 x R.C Car
2 x LEDs (hopefully the same)
3 x AA batteries (for the car)
About 50cm of four strand wire
15 – 20 jumper wires
A few elastics
Some electrical tape
Some solder (lead free)
Tools:
Soldering iron
Wire strippers
Small screwdrivers
Third Hand (for soldering)
Computer (with Arduino software installed)
Step 2: Taking Apart the Car
The first thing that we need to do is take the body of the car. Depending on which car you have you may require some strange screwdrivers. Luckily mine came with standard screws. Also depending on the car you may have to cut off the antenna don’t worry we don’t need it for this project (remember to keep it as it comes in handy latter).
Next we need to take the screw out of the PCB (Printed Circuit Board) so that we can more easily access the brain of the car.
Step 3: Figuring Out the Chip
In order to replace the car’s on board chip with the Arduino we must first find out what each pin on the on board chip controls. To do this Google the name and number of your chip (most cars use this one).If you can’t find a diagram online you can manually find out what each pin does using this guide.
Once the use of each pin is known we can remove the chip (if yours doesn’t have a diagram draw your own or label the chip). I found that because I don’t have a solder braid trying to remove the chip was tricky. The best way I found was to thread the antenna of the car (or similar piece of thin wire) under one pin, then melt the solder and pull up on both ends of the antenna. However the important thing is that you get the chip out.
Step 4: Basic Movement
The first thing that we need to do is solder a piece of wire (10 – 15 cm) to the holes in the PCB that control left, right, forward, backward, and ground (or negative). Once that is done connect the negative wire to ground on your breadboard and then from ground on the breadboard to the gnd pin on the Arduino. Next connect the forwards wire (directly or through the breadboard) to pin 7 on the Arduino. The others follow the same method
Left to pin 2 right to pin 4 and backward to pin 8
THE CODE
This sketch will test out each of the car’s basic movements if your car fails to perform any of the actions double check all connections and ensure that it is connected to the right pin on the PCB and on the Arduino.
Basic Movements Sketch: copy and paste or download the file at the bottom of the page and open it with Arduino.exe
int left = 2; // left connected to pin 2
int right = 4; // right connected to pin 4
int forward = 7; //forward to pin 7
int backward = 8; // backward to pin 8
void setup() // happens only once when the Arduino is turned on
{
// setting all the pins to outputs
pinMode (left,OUTPUT);
pinMode (right,OUTPUT);
pinMode (forward,OUTPUT);
pinMode (backward,OUTPUT);
}
// creating functions so we don’t have to type as much
void go_forward() {
digitalWrite (forward,HIGH);
digitalWrite (backward,LOW);
}
void go_backward() {
digitalWrite (backward,HIGH);
digitalWrite (forward,LOW);
}
void go_left() {
digitalWrite ( left,HIGH);
digitalWrite (right,LOW);
}
void go_right () {
digitalWrite (right,HIGH);
digitalWrite (left,LOW);
}
void go_stop() { // could't use just stop because it's taken
digitalWrite (right,LOW);
digitalWrite (left,LOW);
digitalWrite (forward,LOW);
digitalWrite (backward,LOW);
}
void loop() { // runs over and over again until Arduino is turned off
go_forward();
delay (1000); // car goes forward for one second
go_backward();
delay (1000); // then goes backwards for a second
go_right();
go_forward();
delay (1000); // car will make a right turn for a second
go_left();
go_forward();
delay (1000); //car will make a left turn for a second
go_stop();
delay(1000); // car will stop for a second
}
STOP COPYING HERE
Attachments
Step 5: Incorporating the Light Sensing LEDs
All LEDs produce a small voltage when in contact with light; we will use this feature to sense light with two normal LEDs. If you have photocells you can use them to but you will need to change the code.
First solder a piece of wire (40 – 50 cm) to each leg of the LEDs. Connect the negative ends to ground on the breadboard and the positive end of the left led to analog pin 5 on the Arduino. Also the positive end of the right led to analog pin 4 on the Arduino.
MORE CODE
This sketch will print the value of each led to the Serial monitor via a USB connection.
Place the car (or just the two LEDs) in direct light so each LED receives an equal amount. Look at the values in the serial monitor, this will show by what amount the LEDs differ in their light conductive properties. My LEDs were off by about 2-3 when in direct light. Remember (or write down) how much you’re LEDs differ when in direct light as we will use this value later. Also check how much the LED’s values change when one is in complete darkness and the other in light. If one (or both) of your LEDs are reading in the thousands while under a light bulb you probably have them wired wrong.
LED Values sketch:
//LED values sketch
int ledleft = A5; // positive wire of the left led connected to analog pin 5
int ledright = A4; // positive lead of the right led connected to analog pin 4
int lf = 0; // used to store the value of the left led
int lr = 0; // used to store the value of right led
void setup() {
pinMode (ledleft,INPUT);// this is not necessary because analog pins
pinMode (ledright,INPUT); // have a default setting to be inputs but i did it anyway
Serial.begin(9600); // gets Arduino ready to send info to the computer
}
void loop() {
lf = analogRead (ledleft); // sets lf to the vale of the leftled
lr = analogRead (ledright); // same thing but for the right led
Serial.println ("left led ="); // prints what is in brackets to the computer
Serial.println (lf); // prints the value of the left led
Serial.println ("/t"); //prints a tab
delay(500); // waits half a second
Serial.println ("right led ="); //prints what’s in quotes
Serial.println (lr); // prints value of right led
Serial.println ("/t:"); // prints a tab
delay(500); // waits half a second
}// goes to top of the loop
STOP COPYING HERE
Attachments
Step 6: Bringing It All Together
Now we need to tell the motors what to do based on what the values of the LEDs are. I used a do while loop with if statements inside it. There are many other ways to write this code but I found this way to work well. I’m not a programmer so it probably isn’t the most efficient code but it works.
THE FINAL CODE:
Light seeking robot sketch:
int left = 2; // left motor control attached to pin 2
int right = 4; // right motor control attached to pin 4
int forward = 7; // forward motor control attached to pin 7
int backward = 8;// backward motor control attached to pin 8
int ledleft = A5; // left light sensing led attached to analog pin 5
int ledright = A4; // right sensing led attached to analog pin 4
int lf = 0; // stores value of left led
int lr = 0; // stores value of right led
int x = 0; // used to store absolute value of the two leds
int i = 1; // only used to keep the do while loop open
void setup() //does only once when the Arduino is turned on
{
pinMode (left,OUTPUT); // setting types of pins for each motor and led
pinMode (right,OUTPUT);
pinMode (forward,OUTPUT);
pinMode (backward,OUTPUT);
pinMode (ledleft, INPUT);
pinMode (ledright, INPUT);
}
void go_forward() { // creating functions to reduce the amount of typing later
digitalWrite (forward,HIGH);
digitalWrite (backward,LOW);
}
void go_backward() {
digitalWrite (backward,HIGH);
digitalWrite (forward,LOW);
}
void go_left() {
digitalWrite ( left,HIGH);
digitalWrite (right,LOW);
}
void go_right () {
digitalWrite (right,HIGH);
digitalWrite (left,LOW);
}
void go_stop() {
digitalWrite (right,LOW);
digitalWrite (left,LOW);
digitalWrite (forward,LOW);
digitalWrite (backward,LOW);
}
void loop() { // goes over and over until turned off
lf = analogRead (ledleft); // sets lf to the value of the left led
lr = analogRead (ledright); // sets lr to the value of the right led
x = abs ( lf - lr); // sets x to the difference between the two leds Google it if you want more info on how it works
do {
if (x < 10) { //change the ten to the amount that your leds were of by when they were both in direct //light. This is the sensitivity of your robot and will take some trial and error to get right
go_forward();
delay(500);
go_stop();
break; // exits the do while loop and goes back to the top
}
if ( lr > lf) { // turns left when there is more light on the left side of the car
go_right();
go_forward();
delay (500);
go_stop();
break; // goes back to the top of the loop and reevaluates the leds values
}
if (lf > lr) { // turns right if there is more light on the right of the car
go_left();
go_forward();
delay(500);
go_stop();
break; //goes back to the top of the loop and reevaluated the leds values
}
} while (i == 1); // keeps the do while control loop open
}
STOP COPYING HERE
Final Things
First elastic band the breadboard and the Arduino onto the car, next attach the 9v battery to the car and plug it into the Arduino using the 9v to Arduino cable. Also remember to put batteries into the car and turn it on.
Finished your R.C car should now seek out the light. If not then double check all the connections and make sure nothing is shorting out. If your car just goes straight then your sensitivity is to low and you need to decrease the x < __ number. If your car constantly switches directions your sensitivity is too high and the x < __ number needs to be larger. And make sure the batteries aren’t dead : )
If you have any problems comment them and please rate. Thanks for reading (and building?)
Attachments

Participated in the
Arduino Challenge

Participated in the
Robot Challenge
34 Comments
3 years ago
Cool project!
Any idea on how to control the speed?
9 years ago on Introduction
where to find the chip's name?
Reply 9 years ago
If I remember correctly there was a number on the chip, I googled that and found which chip it is. You can also use a voltam meter and try firing the different pins of the chip and see which ones have a current. Eg. hold down the "turn right " key on the controller and check which pins are getting a signal. Then repeat for all the different commands you want to program into your arduino.
Reply 8 years ago
Can we make it move towards light and how?
Reply 8 years ago
Change the if lf>lr to if lf
(Or the other way around, I can't remember)
Reply 8 years ago
how will it work?
Reply 8 years ago
By firing the pins using the remote and checking the amps coming from the pins you can determine which pin is responsible for any of the given commands. For example if I want to know which pin is responsible for turning the motors on and propelling the car forward I (First check to see which pins are always receiving current, these are responsible for communicating with the remote) push the forward key on the remote (the wheels will start spinning so flip the car upside down) and then check which pins are receiving current, there will most likely be two additional pins, one as an input telling the chip that the controller is pressing the forward key, and the other outputting current to the motors. The one with more milliamps is likely controlling the motors. then write down the location of this pin so that later (one you have the whole chip mapped) you can remove the chip and replace it with the arduino, by soldering jumper wires from the points on the PCB where the chip used to be to the arduino. You could leave the chip on and do the same procedure but I'm not sure it would work, and you may end up damaging the RC cars chip anyway.
Reply 8 years ago
how it will work?
9 years ago on Introduction
where to find the chip's name?
9 years ago on Introduction
where to find the chip's name?
9 years ago on Introduction
where to find the chip's name?
9 years ago on Introduction
Did you use male to female jumper wires or male to male/female to female? What kind of four strand wire did you use? Does it look like an ordinary wire?
Reply 9 years ago
Male to male for the arduino. other wires were "normal" I think they came from a phone cable.
9 years ago on Introduction
Does the RC Car can run normally using the remote control if the Arduino Uno is turned off?
Reply 9 years ago
No. When the chip is removed and replaced with the arduino, I only replaced the pins that control speed. If you wanted to though you could expirement and find out which pins on the chip respond to the radio signal from the controller. After that attach leads to those holes and run them to the arduino. The code would also need to be adapted to send instructions to the forward reverse pins using the radio as a reference rather than the LEDs. So yes it could be done but you would still need the arduino to be attached.
Any way the point was to make it autonomous not remote controlled.
9 years ago on Introduction
I am really not a programmer and I am trying it for the first time. Could you write me a program and test it in your robot? It is for our research project and I am very cautious about it. Please help me for the radio response on the rc. I am using a VX-6 spy car.
Reply 9 years ago
sorry mine has been dismantled for a year or so now. using the arduino for other things. you could just wire up some dummy parts instead of the motors, so instead of a motor plug an led into the same pin, and then watch which ones light up.
9 years ago on Introduction
does the rc car loses it's radio response to the controller?
Reply 9 years ago on Introduction
Yeah, when you remove the chip that came with it it loses all it's programming. It still has the ability to receive the signals, but it doesn't know what to do with them. You could write some code on the arduino to tell the car what to do with the received signals. I haven't do so but I'm pretty sure its possible.
Cheers-Lucas
10 years ago on Step 6
hey friend ...
I want to ask you, about the project that you created.
I want to learn as well as make your project.
if you are willing whether I can learn with you.
Do you genuine Indonesian citizen?
knight_fikri@rocketmail.com