Creating an Arduino controlled RC car isn’t all that hard to do, especially with the Arduino Servo library.
Read the whole step-by-step process here!
I started off by buying a Traxxas Monster Jam Truck. This page has some good information on the RC car, long with some pictures of the internals. This car was chosen because its frame and suspension looked pretty beefy, and it was the cheapest car in the local hobby store!
To get a good build area, I stripped off everything I could.
I created a bracket to hold the Arduino and ESC (Electronic Speed Controller).
Next I soldered a couple of 3 pin connectors onto an XBee shield to make hooking up the ESC and steering servo easier. Notice the red wire? I realized the ESC outputs 6v on the power line and not 5v. That’s why the power line is plugged into VIN, which is put through a 5v regulator.
- Servo GND = GND
- Servo PWR = 5v
- Servo Signal = Pin 13
- ESC GND = GND
- ESC PWR = VIN
- ESC Signal = Pin 12
Next thing I did was drill some holes to hold the bracket above the battery.
I swapped out the wimpy NiCd battery with a beefy 10aH LiPo.
I ended up clipping the sides of the bracket screw holes off, which makes putting the bracket on a lot easier.
Throw on some XBees, and the hardware side is more or less done. A happy accident is the ESC’s power button, which I haven’t seen much on ESCs. But the power button allows the rover to be turned on/off without unplugging the battery.
The programming side was a little shaky starting off. I knew how to control the servo and the brushless motor, but I had no idea what the values were. After some trial and error, I figured out the values:
- Stopped = 1500us
- Reverse = 1500 (min) – 1000us (max)
- Forward = 1500 (min) – 2000us (max)
An interesting note: Going into reverse, the first time, causes the car the brake, the second time makes the car move in reverse.
And my servo values:
- Right = 50
- Straight = 90
- Left = 130
The servo values might be different for different cars, but the ESC values should be the same.
To move the car you can use the buttons on the screen, WASD, or the arrow keys.
To program the Arduino side I started off with just trying different values:
After trying different values, I used serial_sync from MSL to control the speed through the serial connection. The serial_sync system works by creating a list of values on both sides of the serial link. When one side changes a value, the value is updated on the other side of the link.
First thing to do is download the files for the serial_sync.
Put these files in your Arduino sketch folder.
Include the header file in your Arduino code:
Create a serial_sync object:
In the setup function, call the setup() function of the serial_sync object:
In the loop function we have to make two calls. The first call updates the receive (RX) side of the link, always do this at the start of the loop function. The second call updates the transmission (TX) side of the link, always do this at the end of the loop function.
That’s all the setup needed to implement a synchronized serial link. Let’s try setting a value. The call below will set variable 0, to the value 127:
Let’s also read a variable’s value, lets do this with variable 2:
My ESC seems to arm with the button on it, which is great! As long as you do not have an ESC that requires a signal from the Arduino… Add the code segment below to arm your ESC, place it at the beginning of the setup() function of the rc_test Arduino code attached below.
Below are links to the GUI program and the Arduino code I used: