This instructable is intended to offer a method of converting a remote control car into an automated car. The final result is a vehicle that can respond to its environment through a proximity sensor and thus be coded to drive through a given path. Although small automated cars function mostly for entertainment creating them is an excellent exercise in circuit building. While converting our RC car we learned useful electronics skills such as how to use an H-bridge, how to create a shield with the computer program Eagle and how to program an Arduino.
Step 1: Materials
The following materials are necessary for the project.
Step 2: Assembling The Car
Depending on what materials you begin with the first step in converting an RC car into an automated car requires hacking into the actual vehicle. That is, to control the motion of the car it will be necessary to access its motors. For most cars this requires disassembling the purchased vehicle. In this example, however, the vehicle we bought was delivered in parts so we describe the analogous process of constructing it.
Assembling a commercial RC car is relatively straight forward. The only step that may cause confusion is the addition of the car's axle, notably the front one. The front axle is also fragile and one should note to avoid running the front motor run for long stretches of time so that the axle does not snap off. Once the axles and corresponding gears have been attached one effectively has a working car minus the motors. The instruction guide provided with the car may inform you to wire the motors to the batteries. This is however where one stops the original assembly and begins to hack the car. At this point it one should remove or disregard the provided receiver chip from the inside of the car.
With the rest of the RC car assembled as appropriate one should then gather the materials described in Step 1 and identify the unconnected leads. Overall there should be seven unattached wires available to be hacked. There should be two leads from each of the motors and two leads from the power supply of AA batteries. One of the AA battery leads also splits into two more leads. Using our method these seven leads then are routed out to an H-bridge. General information on the H-bridge is given in the next step. Note that a data sheet is also attached for reference.
Step 3: Arduino Basics
The Arduino Uno was an essential part of our method of hacking the car. If you don't have an Arduino Uno or Leonardo already you can get one for $20-25 dollars online. The Arduino is very important because it is the tool which lets one upload code to a circuit. This is enabled through a USB port which one connects to a computer through a cable. If you look closely at the picture provided you might notice that the Arduino has pins for a number of outputs as well as 5 volts and ground. The 5 volt output, which was powered by a 9 volt battery attached to the Arduino's other port, provided the power for the proximity sensor and LED's. In our example, we attached a wire from 5V on the Arduino as well as outputs 5, 6, 10, and 11 to the H-bridge. All the pins other than 5V and ground are effectively equivalent, other than whether they deliver AC or DC, so our choices were arbitrary. Effectively you can think of the Arduino as a middle man which takes code from the computer and relays it to the H-bridge. As long as you wire 5V and ground correctly it should be simple to use.
Step 4: The H-Bridge
For this project, we needed a way to switch the direction of the motors so we used an SN754410 (full) H-bridge which has 8 pins. A full h-bridge as opposed to a half h-bridge allows for changing directions for two motors instead of just one. The datasheet of the one we used can be found on the link in the materials section above. We used one side for our driving motor (positioned in the back of the car) and the other side for the steering motor (front).
The order of the pins reading counter-clockwise from the semicircle are: enable, input, output, ground, ground, output, input, and vcc supply. This is shown in the picture above. On the other side of the bridge the pins are inverted (enable and vcc pins are on opposite corners).The inputs will be how the arduino communicates with the h-bridge and the outputs are how the h-bridge communicates with the motor. The leads on the motor do not have to be positioned in a particular order. The enable pins are used to "turn on" the h-bridge and should always be supplied with power. We used the 5 volt supply of the arduino to power the enable pins but they can also be powered by one of the pins on the arduino as long as they are always set to HIGH. If the second option is chosen then an example of how the code would look like for one side of the h-bridge would be the following:
int en1 = 4;
A significant piece to remember is that when testing one motor, the vcc inputs on each end of the h-bridge should be connected to power (in our case it was the four AA batteries). We are not completely sure why that is the case but using a single side of the h-bridge still requires both vcc inputs to be powered.
Another significant piece to remember is that since there is a significant amount of current passing through the h-bridge, a heatsink should be used for safety. Using the h-bridge for short bursts of time should be fine without a heatsink.
Step 5: Wiring the Motors, H-bridge, and Proximity Sensor
Wiring the motors and proximity sensor to the H-bridge is the most difficult part of hacking the RC car. A good way of creating this circuit is to use a bread board, as shown above. However, if you follow the diagram we drew you should be able to construct it without much effort. Start by placing the H-bridge in the middle of the board and then secure the Arduino to the top part with a zip tie. Next attach the proximity sensor to the Arduino and the motors to the H-bridge. Then it is a simple matter of connecting wires between the Arduino and H-bridge. This process is illustrated in the last picture. Note that there are only two pins for ground on the Arduino so it will be necessary to create a row or column on the bread board that is all ground. It may also be helpful to create a row or column on the board that is entirely 5V and route the 5V pin on the Arduino to it. If you are confident wiring a circuit there are obviously many ways to modify the circuit we created but you may want to copy it exactly to save time.
Step 6: Alternative to Bread Board
If you want to make the wiring of the automated car particularly compact and durable then you might consider making a circuit "shield." This involves printing out a circuit design onto a sheet of copper and then soldering the desired wires and circuit elements where appropriate. Obviously it is unlikely that one might own the equipment necessary to print a circuit on a sheet of copper. However, if you are a student at a university it is very likely that you might be able to gain access which we highly recommend. There is a free program called Eagle available online which one can use to design such a shield. Here is a link:
A typical final design which we created is shown in the picture above.
Step 7: Example Code
Once you have a working circuit in place there are a huge number of opportunities for code that you could upload to the car. With a proximity sensor that can inform the car to move forward and back as well as side to side it is theoretically possible to program the car to drive any desired path, such as through a maze or obstacle course.
The following code that we offer as an example is particularly simple so as to be easy to follow. If you have no coding experience we would recommend copying and pasting it into your Arduino terminal and then tweaking it as desired. For example start with changing input values from "LOW" to "HIGH" or vise versa which will change the direction of the given motor. Note that our code includes commands for LED's which our car carries. The coding for these functions in the same way and can be ignored if your car has no LED's.
Also, if you don't have an Arduino terminal downloaded on your computer already you can obtain one for free through the following link:
Here is our example code exactly as it was entered into the Arduino terminal:
int sensorValue=analogRead(A0); Serial.println(analogRead(A0));
Step 8: Further Ideas
Hopefully this instructable was thought provoking regardless of whether or not it was useful. There are lots of possibilities for fun and interesting projects to create with an RC car and in fact our example of transforming one into a self automated vehicle barely scratches the surface. We only added two LED's to our car which indicated which direction the driving motor was running. It would be definitely possible to add several more LED's to the circuit which could turn on depending on the speed or voltage of the motor, serving as an effective speedometer. Another, somewhat ridiculous feature, that we envisioned adding was some kind of defense mechanism. That is, the car could launch a small projectile after a certain point in its path code. This would require some ingenuity in creating a launcher but again would be totally feasible.
We encourage you to buy an RC car and play around with its circuitry in some way. For us it was a very entertaining project and we learned a lot of electronics along the way!
We would like to say a special thanks to Pomona College for providing us with the materials for this project and to Professor Whitaker and Anthony Grigsby for their support and help.