# Arduino/RC Toy Hack
## Inspecting RC Receiver

Bottom of RC/Motor control circuit taken from a toy RC car. The black wire attached to a corner is the receiving antenna. The orange and green wires are soldered to the motor 2 output. The black and red power wires go to a 9Volt battery snap type clip which powered the car. The red wire has broken off the board and has a switch in it. A single green wire is soldered to motor 1 + output.
The bottom is covered with resistors and capacitors. They are all surface mounted.
This is the top of the motor control/RC receiving circuit board. Maisto is the name of a RC car company. The white lettering is part of the silkscreen on a printed circuit board. The IC number did not lead to a product data sheet. Q stands for Transistor. Z stands for zener diode. M stands for motor. B stands for battery. L1 stands for inductor that has been replaced by a wire. The only inductor on the board is enclosed in white plastic. C stands for capacitor. L+ and L- are perhaps an unused LED output.

## Guessing what wires In and Out Do

The first step was to replace all the wires (except the antenna) with solid wires that went all the way through the holes of the circuit board and solder them in place. The hacking goal is to figure out what the wires are for. The art work on the top of the circuit board enabled this guess:
       Antenna (black)
       Power + - (green, orange)
       Motor 1 + - (green, orange)
       Motor 2 + - (green, orange)
       LED + - (green, orange)

## Powering Arduino and RC receiver

The next step is to get the arduino powered up and figure out how to power the RC receiver/motor controller. The goal is to combine them and power with one device. Because it is easier to physically connect the arduino to power through a power adapter or the USB cable, the goal was to attach the RC circuit to the arduino power. It may have been safer to the arduino to run it off the RC receiver power. Maybe in the future this is what will be necessary.
The next step was to figure out what Vin on the arduino was. Was there enough power coming out of that pin to power the RC receiver? A test was made. A 9 volt wall adapter was plugged into the arduino. 8.3 volts appeared on the pin. But could enough current be drawn from this pin? Would it cripple the Arduino?
Attaching the RC Reciever to Vin dropped the voltage to 8.28 volts ... hardly any change! The next step was to look at the motor outputs. Would the RC transmitter cause the voltages to change? Could these voltages be detected by the arduino? Would 8.28 volts be enough to power the RC receiver that originally was attached to a 9 volt battery?

## Testing

The first step is to see if the Motor and Light wire pairs change voltage without being plugged into the arduino. The RC transmitter has two controls, a wheel and a button with up and down arrows. This probably corresponds to the motor wire pairs. The RC transmitter has a battery and power on/off switch. After powering it on and pushing the wheel fully Counter Clock Wise (CCW), a voltage of 7.4 volts was recorded. Success!
Pushing the wheel fully clock wise resulted in a negative voltage. This is confusing because only a positive 8.28 volts was powering the RC receiver. Then it was noticed that the grounds (orange) wires were all electrically isolated from each other. So probably the RC circuit was merely reversing the wires. This means the negative lines or grounds are floating .. the grounds are not tied to each other. Thus when positive 7.4 volts, the green is positive and the orange was at the same ground as the arduino. Then when the wheel is pushed clock wise, the orange is positive and the green is at the same ground as the arduino. So in fact a positive voltage was being delivered alternately to the green and orange wires. They clock wise position merely looked negative because of the way the voltmeter was connected.
The up and down switch did the exact same thing to the motor 2 pair. The L+ L- pair did nothing. So the wires to them were removed.
Every attempt was made to turn the wheel and push the up and down buttons very slowly to see if the voltages gradually changed. The voltages flipped. There was no gradual change. This makes sense. A variable resistor or potentiometer is expensive, gets dust and grit in them and has a short life unless they are very expensive. Two of them may cost as much as the rest of all the components in the toy car. Probably if the RC transmitter is opened up, the wheel and up/down buttons will be attached to switches. A next step may be to replace them with potentiometers. The RC transmitter and receive circuits might be able to transmit a variable voltage. It all depends upon how the rest of the circuitry is configured. Hopefully the rest of the circuitry is generic and will work in RC toys where the speed and turning is variable. It is worth a try ... later.

## Hooking to Arduino

After testing with the Vin 8.3 volts, the same tests were repeated with the 5 volts output of the Arduino. The RC receiver still worked. And the voltages on the motor pairs swung from -5 volts to + 5 volts. This is good news. After reading the amtel manual, it appeared that the Arduino might work with 8.3 volts. But there was not need to test this. 5 Volts worked!
So the green wires are positive and orange wires are negative or ground. But the orange wires are really positive while the green are ground. So all four can be hooked up to the arduino. The idea was that three states could be detected by the arduino analog to digital pins. The power pair green was hooked to 5 volts. The power pair's orange was hooked to ground. Then motor 1 green and orange were connected to A0 and A1. Motor 2's pair were connected to A2 and A3.
The blink program was running at all times while the RC receiver cables were plugged into the arduino. This was done slowly watching the arduino led blink to make sure the RC receiver did not damage or shut down the arduino. Nothing happened. This was done with the 9 volt, 650 ma power adapter plugged into the arduino.

## Arduino Test Program

The first example program in the analog menu called "AnalogInOutSerial" worked. It displays a number between 0 and 1027 depending the voltage of A0 on the serial monitor which is a window that has to be opened by clicking on an icon to the right of the upload icon ... after the upload has been completed. AnalogInOutSerial defaults to A0. This was attached to the green motor 0 pair.
Was expecting 0 to 1027 for one half of the wheel motion and nothing for the other half.
Was expecting to hold at 0 or 1027 if the wheel was held in any of the three positions: extreme left, middle (default) or extreme right. The middle did not require any holding, but the output drifted.
This behavior can be corrected with software. The voltages did not reflect this drift. Can not think of anything that would cause this.
Because there was no preceivable difference between the green and orange wires of each pair, the orange wires were taken off the board.
None of the chips heated up at all. So guessing that the RC receiver was drawing very little power and tested with just power from the USB cable. It worked!

## Distance Test

The remote has to be within 18 inches of the receiver in order to work on the 5 volt arduino supply.
To get more distance, need to increase the power to the RC receiver. Powering the RC receiver with the 8.3 volts results in the analog to digital convertor of the arduino messing up. So need to construct a voltage divider on both motor + circuits to knock the voltage down to 5 volts.

## Next Steps

* Put voltage divider on the Motor + circuits and increase RC receiver power to increase transmit range ... or check batteries in the transmitter.
* Replace switches in RC transmitter with pots
* Start working with the software to extract four states from the changing values:
                power on
                increasing
                continue without change
                slow down