Hack a RC Toy (MakeIcT)

April 7, 2013 in Projects

I created the following instructions to be part for the workshop that I will be giving for our local hacker space (MakeIcT). The idea is to expose the next level of applied knowledge for the members. The project consists of hacking into the circuitry of a cheap remote control car. We found a very cheap RC toy online the Thunder Tumbler, which makes a great initial platform to start playing with H-Bridges, Arduinos, and sensors. Our main sensor will be a sonar sensor to detect any obstacles, but we will also reference to a infrared sensor. We will use the H-bridge that comes with the toy, to control the motors, using an Arduino nano. Programming wise, we will introduce the concept of controlling speed via PWM, how timers are used in the Arduino environment and what to do to improve control of the speed of the motors.

Tools Needed

At bare minimum the following tools are needed to be able to accomplish the project.

  • Soldering Iron and Solder
  • Solder wick and/or sucker
  • Scrap Cables
  • Wire stripper and cutters
  • Hot glue gun
  • Exacto knife

    Materials Needed

  • Thunder Tumbler Remote Control Car – or equivalent (differential wheels)
  • Arduino Nano (recommended due to size)
  • Sonar Sensor (HC-SR04 based)
  • Qty:6 x 1N5817 Diodes – Noise suppression
  • Qty: 5 Capacitors – Noise Isolation
  • Batteries, Wire


  • Servo Motor
  • Li-ion rechargeable batteries
  • IR Sensor (Sharp GP2D120)
  • Li-Ion charger

    Block Diagram

    We will base our discussion of this project based on the following top level block diagram. It helps visualizing the complete concept before digging into the details.

    Block diagram


    Hardware Building Blocks

    Pulse Width Modulation (PWM)

    PWM is a fancy word to describe the turning ON and OFF a signal, with the attempt to control the speed of a motor. PWM is also used to control the intensity of a LED. It works by turning OFF and ON the signal by a defined amount of time (PERIOD). The ratio of ON vs. OFF in the PERIOD defines the speed of a motor or the intensity of an LED. The longer the ON time compared to the OFF time the faster the motor goes or the brighter the LED is. So if we turn ON the signal 80% while OFF 20% of the time intervals that we pick then the motor will see 80% of the power on average. On the same token if we turn ON the signal 10% and OFF 90% of the time then the motor effectively will see 10% of the power on average.


    Graphically it looks as following:

    PWM Signal

    (source: http://Arduino.cc/en/Tutorial/PWM)



    Each of the vertical lines show the period of time. This period is refer to in terms of frequency (calculated 1/PERIOD). Frequency is defined in the term of Hertz. If you do 1 push up per second you are doing push-ups at a frequency 1Hz. If you do 10 push-ups per second, you are doing push-ups at a frequency of 10Hz. Why is this important? Because that is the speed at which we will be turning ON and OFF the signal to the motors. We would normally pick 100Hz-1000Hz for small motors.

    Duty Cycle

    So once we defined how fast we are switching the signals ON and OFF, we need to pick the ratio of ON and OFF (Duty Cycle). Back to the push-up the amount you are upvs.s the amount you spend down resting is what is used to define the duty cycle. For example, if we apply a signal to the motor for 2sec and OFF for 9 sec, then ON for 2 sec and OFF for 8 sec, then ON for 2sec OFF for 8…etc, we have a PERIOD of 8+2 = 10 sec. The frequency = 1/10 sec = 0.1Hz. The ON Duty Cycle is 20% (2sec/10sec), so the motor sees only 20% of the power, equates to run slow speed. The closer we get to 100% the more power the motor sees the faster it moves.

    In short PWM uses a frequency and a duty cycle to control the speed or intensity of a voltage applied to a load. We will use this to control the speed of a motor.


    The Arduino Nano has a 16Mhz oscillator. The Arduino IDE environment set the prescalar to 64 effectively ensuring that Timer 0 uses a 64 prescalar. If we want to run the motors at a higher PWM frequency than the default ~400Hz then we have to change the prescalar, in the example described here we will use a prescalar of 8 to increase the PWM frequency allowing us to control the RC car better a lower speeds.

    When modifying the register to change the PWM frequency, you will have to make changes to the Arduino files to account for the new prescalar and still maintain the delay functions.


    The H-bridge is the most common way to control a motor back and forward. It does this by switching the polarity of the motor leads so that the motor moves in one direction or another. In its simplest form the H-bridge looks as following:

    Basic Hbridge

    When the TOP-RIGHT and the BOTTOM-LEFT switches are ON, then the motor turns one way. You can stop it by closing both BOTTOM switches or opening both.

    We will hack into the H-bridge already used in the RC car. Tapping into the lines needed by the Arduino to be able to control the motors.

    Why not connect the Arduino directly to the motors? It is all about the current needed by a motor and what the Arduino can deliver. The pins in an Arduino should not draw more than 25mA or the chip will start to suffer and eventually burn. Instead we use an H-bridge made out of MOSFETs to control larger currents needed by the motor, with smaller currents controlled by the Arduino

    Differential Driving

    This is the simplest way to control a robot. Each wheel has a motor. You spin both forward or backwards to move ahead or reverse. When you want to move right or left, you move one wheel forward and the other backwards depending on which side you want to turn. This allows 360 degrees turn radius


    Sonar Sensor

    The Sonar Sensor works by generating a sound and detecting the sound that bounces of an obstacle. Similar to bats. The sonar sensor generates ultrasound, undetectable to humans. It is ultrasound due to the frequency at which the sound waves vibrate. It is used based on the knowledge that sound waves travel at a speed of 343 m/s (1,126ft.t/s) in dry air at room temperature and pressure. So if you send a sound wave and sit and listen you can determine how far away and object is.

    (source: http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/28015-PING-v1.6.pdf)

    Sonar Basic  image

    To sense an object we set the TRIG pin high for 10 µsec then back LOW. This signal initiate 8 bursts of ultra sound at 40KHz called “chirp”, and any object in front of the sensor will produce a pulse in the ECHO line, proportional to the sound sensed. We measure how long the ECHO signal remains ON for, and use the following formula to get the distance:

    Distance in cm = Pulse Width (in µSec) / 58

    Distance in in = Pulse Width (in µSec) / 148

    If nothing is detected the Pulse Width will be 38msec, the detection range is from 2cm to 450cm (pulse widths from 116 µsec to 26100 µsec). So you will need to have a WORD/LONG size variable to measure that distance.


    The HC-SR04 module parameters are as following

  • Working Voltage: 5V (DC).
  • Static current: Less than 2mA.
  • Output signal: Electric frequency signal, high level 5V, low level 0V.
  • Sensor angle: Not more than 15 degrees.
  • Detection distance: 2cm-450cm.
  • High precision: Up to 0.3cm.
  • Input trigger signal: 10us TTL impulse.
  • Echo signal: output TTL PWL signal

    Hacking the RC Car


    1. Remove battery cover and container

    2. Remove top cover by taking the 11 screws from the bottom.


    3. Next remove the 2 screws from the side and pry the car open


    4. Carefully remove the antenna cable with a soldering iron


    5. Note the color codes from the motors into controller


    6. Remove the screws holding the controller board

    7. Remove the grey cover by removing the screw under the cover



    1. Remove all cables going into the board. Note their location

    2. Remove the RC IC from the board

          a. You can de-solder it or cut it off and clean the board

    3. Install capacitor (note negative marking) as shown in the picture.

          a. Notice this capacitor will help smooth the power line

    image     image

    4. Solder a piece of wire to ground for later reference point. (Red arrow)

    5. Add protection diodes across the H-bridge main transistors (8-total), figure below:




    1. Add wires to the pads of Pin 6,7,10,11 of IC2 (removed from the Hacked board)

  • Wire from Pin 6 (P6) solder to D9 of Arduino
  • Wire from Pin 7 (P7) solder to D10 of Arduino
  • Wire from Pin 10 (P10) solder to D11 of Arduino
  • Wire from Pin 11 (P11) solder to D3 of Arduino

    Arduino Connections

    1. Solder a diode to the Vin input of the Arduino, with the band towards the board.

    2. Solder a wire from the battery Positive via diode to the Arduino input power

    a. Use the switch and add a wire to run to the diode

    3. Solder a wire from the battery Negative (GND) to the Arduino input power

    4. Solder a wire from the 5V pin to the Sonar Pin 5V power

    5. Solder a wire from D2 to the TRIG Pin in the Sonar sensor

    6. Solder a wire from D12 to the ECHO pin in the Sonar sensor

    7. Solder a wire from GND to the Sonar GND

    8. Solder a wire from Pin 6 RC controller to D9 of Arduino

    9. Solder a wire from Pin 7 solder to D10 of Arduino

    10. Solder a wire from Pin 10 solder to D11 of Arduino

    11. Solder a wire from Pin 11 solder to D3 of Arduino




    Sonar Mounting

    You need to mount the sonar at least 2 cm (0.78 in) from the front of the car, to allow enough range for the sonar to read good values close to the car. Things to consider are the reflections from the flow, or items inside the car itself. So as high as possible is better, but that leaves you vulnerable for low obstacles. More sensors might be needed such as a bump switch, etc.

    Place a thick bead of hot glue around the top and the sides of the sonar. Make sure that the connector points to the bottom. Also make sure that the sensor point is straight.

    The following location works well in the RC toy we are using, but it will have some trouble with short obstacles:



    Schematic Definition

    RC Controller Circuit


    Simple Software flow




    · Under no circumstance can the program enable both legs of the H-bridge or the MOSFETs will suffer due to a short caused by the program

    · If the robot is moving too fast it will have a hard time stopping so make sure you have enough distance measured to allow for breaking time

    · Different surfaces will limit the speed of the car

    · The sensor will not always detect an obstacle, it just happens

    · Motors will run faster on hard floors than carpet

    · It is harder to turn on carpet than floors

    · Timer0 is used on the Arduino, remember that some functions might not perform well when changing the timers.


    Simple Code

    The simple code is not very efficient at controlling the speed of the motors. But it was written using all Arduino functions and timer

    Advanced Code

    The advanced code uses the timers by configuring the registers of the Arduino Nano outside the regular Arduino environment. While the Arduino sets up the timers for the use of other commands, care was taken not to use Timer 0 as to have the least impact to the Arduino commands. Therefore we pick strategic pins of the Arduino Nano that can be used with the Timer 1 and Timer 2 of the Atmel chip. One of the commands that is affected will be the generic Servo routines, so if you use this code make sure that you do not use Timers 1 and 2 commands, as you might get unexpected behavior.