Introduction: Light Seeking R.C Car Hack (with Arduino)

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Step 5: Incorporating the Light Sensing LEDs

Picture of 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

Step 6: Bringing It All Together

Picture of 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?)

Comments

CathH1 made it! (author)2016-05-17

Merci, super explication, parfait pour un premier essai arduino. Le meilleur tutorial, d'apres moi ! Photo avec ma bouillotte motorisé RC.

JohnM49 made it! (author)2015-02-24

It works a treat, just need to tweak the sensitivity of the LED's. The biggest problem was soldering to the RC Cars PCB as it was so tiny: http://www.et.byu.edu/~bmazzeo/LTR/tech.phtml

Wow good job, for soldering little boards I would recommend a solder sucker, makes taking those chips out and cleaning up any mistakes much easier. https://www.adafruit.com/products/148

Thanks very much for posting your project.

JohnM49 made it! (author)2015-02-24

It works a treat, just need to tweak the sensitivity of the LED's. The biggest problem was soldering to the RC Cars PCB as it was so tiny: http://www.et.byu.edu/~bmazzeo/LTR/tech.phtml

shawnyap (author)2014-09-17

where to find the chip's name?

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.

Can we make it move towards light and how?

Change the if lf>lr to if lf
(Or the other way around, I can't remember)

how will it work?

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.

how it will work?

shawnyap (author)2014-09-17

where to find the chip's name?

shawnyap (author)2014-09-17

where to find the chip's name?

shawnyap (author)2014-09-17

where to find the chip's name?

shawnyap (author)2014-07-06

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?

Male to male for the arduino. other wires were "normal" I think they came from a phone cable.

shawnyap14 (author)2014-06-11

Does the RC Car can run normally using the remote control if the Arduino Uno is turned off?

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.

shawnyap14 (author)2014-05-31

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.

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.

shawnyap (author)2014-04-18

does the rc car loses it's radio response to the controller?

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

mfiqri (author)2012-10-14

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

bluenosedwill (author)2012-07-20

Hi i have been following your intructions and have found it real helpful. i have got to the stage of adding LEDs and i do have LDRs and would like to use them. could you tell me how i need to change that code to use LDRs instead?

any help would be great

thanks a lot

LDRs are light dependent resistors right? Take a simple program that reports the value of the LDR and transmits it to your computer via serialread, serialwrite, next place the LDR into the light and then into the dark, then follow the same directions as with the LEDs. If that didn't help reply and I will try to write up a program.

yeah thats right. seem to have got it working only the right turn connection keeps coming loose. i need some soldering first aid and it should get working. What i also need to do is slow the thing down as it goes full steam ahead all the time and slides everywhere. any idea on how i can reduce the speed? what about resistors on the Volts in?

thanks for getting back to me btw!

BNW

I never experimented with slowing it down but I would recommend putting resistors on the positive side of the motors. Or you could just give it larger heavier wheels.

JoeChege (author)2012-05-13

I tried to replicate the project, while I was taking out the chip, I accidentally ripped one of the thing with the 222 number I don't know what they are, now my car doesn't work when I connect the Arduino to the car and upload the code, it doesn't bulge, Would that have caused the car not to work? Do I have to buy a new one?

Give me a day or so. I have to find my car and find out what it is then I'll reply back. No chance you could put the piece back in.

K I looked at my board, when you say it has 222 on it is that on the component or the PCB. if possible could you comment a pic of the type of piece that you're talking about. It would really help to have some more description, nothing on my board has 222 on it (all remote cars are different).

iceng (author)2012-05-12

Impressive understanding of the RC electronics to do the hack.

The video looked like dark following ?

You could put a few bright remote switched LEDs and put this RC through
a whiz bang drive and seek :)

A

Zaphod Beetlebrox (author)iceng2012-05-12

at the time it was dark seeking because my house was mostly vary bright so I switched it.
Would have tried you're led test but it has already been dissembled and my arduino is now busy shooting zombies.
b
ut later I might try it, first I have to work out the code for bump switches.

iceng (author)Zaphod Beetlebrox2012-05-12

Cool :)

Mr Jaderman (author)2012-04-30

That's cool how you utilized the RC cars circuit like that. Real nifty! I'll prolly be using that idea in other projects.

Thanks post a pic if you do.

mohtaprashantrocks (author)2012-04-11

This is so on my list to do when i get my hands on an Arduino that is

Thanks hope you have fun building it.

About This Instructable

23,802views

48favorites

License:

Bio: Second year engineering student studying at the Beautiful Okanagan campus of The University of British Columbia. I like to tinker with electronics and meddeling with ... More »
More by Zaphod Beetlebrox:Ruby's GingersnapsHow to Make your Own PopcornHow to Make a Rustic Leather Shaving Kit
Add instructable to: