Intro: Control an RC Car Using the Computer
In this project, I transformed a cheap RC car belongs to my son into an autonomous car using few simple steps and Arduino. The car can be controlled with the PC through serial/USB port, or can be driven autonomously via the Arduino.
Step 1: Open the Transmitter, Understand How It Works, and Connect Wires
After opening the transmitter, you have to check first what "stimulates" a given command. For my transmitter, I found connectors that "touch" four jumpers to pass four commands: forward, backward, left, and right. Jumper 1 (J1) is for backward command, jumper 2 (J2) is for forward command, jumper 3 (J3) is for left, and jumper 4 (J4) is for right commands.
I measured the voltage between the connectors and the positive (+) and negative (-) sides of the batteries. I found that these connectors are nothing but the ground (or the negative side of the batteries). This means that to make the car goes forward, we have to connect J2 to the ground (batteris' negative (-) side). I connected long wires to the jumpers and to the ground and I labeled them.
To avoid using batteries with the transmitter, I connected two wires to the positive (+) and negative (-) sides of the batteries' pins. No need to use batteries anymore if I give 3 V to these power wires.
Step 2: Solder a Simple "translation" Circuit
Now we have to make a simple circuit that uses the Arduino commands to connect the wires connected to the jumpers to the ground (-). This circuit (check the figure) "translates" the Arduino commands into transmitter commands. It is very simple, and uses four NPN transistors and 4 resistors. I used 3x2N3904 and 1xBC548 transistors (no 2N3904 left at home!), and 4x 1K resistors.
Step 3: Set Up the Hardware - Write the Arduino Code
Solder the circuit to the transmitter wires (jumper wires), and connect it to the Arduino. You are now ready to write the Arduino code.
I started with a simple code that receives data from the Arduino serial port and moves the car accordingly. I assigned a letter for each command: I choosed "F" for forward, "B" for backward, "R" for right command, and "L" for left command, and "S" for stop. Whenever the Arduino receives a letter from the PC, the appropriate command is sent to the transmitter. Pin 11 of the arduino is connected to the forward command in the transmitter (J2), pin 10 to the backward (J1), pin 13 to the right (J4), and pin 12 to the left (J3).
Now you can use any program that sends these letters from the PC (Visual Basic, C++, MATLAB, JAVA, etc.).
You can also right a code that makes the car move according to previously planned path.
Note: You can use the transmitter either with batteries or with external power supply connection, but ensure to connect the GND of the Arduino to the (-) side of the power supply/batteries connectors.
Step 4: Further Improvements - Future Work
My goal was to make a cheap experimental autonomous robot for research purpose. I am thinking to use an over head webcam to detect the position of the robot (the RC car), and send this position to the computer which controls the car according to Artificial Intelligence (AI) algorithms. Because my work in robotics is based on MATLAB, I developed a MATLAB code that allows the user to control the car using the keyboard arrows and space bar. In the future, I am planning to update this project to become a complete Unmanned Ground Vehicle (UGV) with webcam feedback.
The main MATLAB code is "RC_CarControl.m", and "getkey.m" is a function that reads the buttons pressed on the keyboard. Once the position feedback code based on image processing techniques is finished, it will be easy for me to merge the two codes.
Step 5: Happy End
And here is the finished project with the smiley face of the owner...