Introduction: RC Car to Autonomous Arduino Robot

About: I'm currently a student, and playing around with ideas and plans for things to build keeps me preoccupied.

Have you ever desired to construct a simple autonomous Arduino robot? I was inspired to build a basic Arduino robot in order to aid my understanding of the Arduino, the Arduino IDE, and the operation of ultrasonic sensors and motor drivers. And so, I have built such a robot with the intent to teach others as well.

Please note that throughout the course of this project, I changed the wiring a few times due to the fact that:

-Some wires were messily too long

-Some wires were not color coded accurately

-Some wires that needed PWM were not in the right Arduino pins

With this being said, following the wiring explanation in step 7 and the sketch comments will give you the correct wiring description.

*If you enjoyed this Instructable, please vote in the 'Make it Move' or the 'Robotic' contest*

Step 1: Necessary Materials

To begin the construction of this robot, only a few, low-cost materials are required. Now, I have not located the stores I have bought them at, due to the fact that I have purchased the following on sites such as Ebay and Amazon, in which sales end unpredictably, and others begin with the same abruptness. By purchasing at these stores, this robot can be made for around $40, provided ALL materials are bought at this time. Or else, the cost should be significantly less. Any who, the materials necessary are:


-An L298N motor driver

This motor driver is a duel-channel H-bridge circuit, which will provide the power for both motors, and the ability for both of the motors to run forwards and backwards. Enabled with PWM (Pulse-Width Modulation), the user can change each motor's speed to fit their needs.

-An HC-SR04 Ultrasonic sensor

This module is a sensor that detects objects at 'n' distance by preforming mathematical operations based on the reception time of the initial frequency it emits. (Waves are emitted, bounce off said object, and return to be processed by this unit)

-A Microcontroller

The brains of the robot. In this case, I am using an official Arduino Uno R3 microcontroller board.

-A power supply for the microcontroller and the motor driver

A 7-12 VDC power jack is needed to run the Arduino microcontroller, and the motor driver requires at least 5 VDC for this project. You can use the battery box in the RC car for both however, so no other power supply is needed.

-A cheap RC car

This is the platform in which to modify for our needs. Keep in mind that for our purposes, we will only be dealing with two DC motors, one for the rear wheels, and one to steer, which are found in cheap RC cars. More luxurious RC cars feature more complex systems such as servos, which can work, if one so desires, but will be forced to greatly modify the code and hardware intended for this basic project.

Step 2: Algorithm Development

In order to build this robot, I decided first to create a general idea of how it would respond to objects, with simplicity in mind, through the form of a flowchart. Above, you can see that if an object is equal to or less than n centimeters away, then the robot will reverse to the left for x seconds, or else it will drive for y seconds straight forward. With this principle, let's move on to the actual assembly.

Step 3: Chassis Preparation

On the RC car's underside, screws hold the exterior to the actual chassis. You will need to locate these screws and remove them. Try not to lose them for a further step. Once the exterior is removed, flip the chassis so it is in proper orientation. Note both motor casings, along with the main controller casing. (Typically in the direct middle of the chassis) You will need to play around with the visible screws and such in order to reveal the motor and controller casings.

Step 4: Controller Transplant

Begin by locating both wires of the rear motor, both wires of the front motor, and both wires of the battery box. There should be six total. Cut each wire as close to the controller as possible to make their leads as long as possible. Then, of course, strip the ends for easier use if necessary.

Step 5: Preparation and Motor Driver Installation

You will need to plan where you will mount each component. When you have found the location where you want to mount the Arduino, clear any obstruction to allow the microcontroller to lay flat. I have chosen directly above the battery box to mount mine.

Look for a good location for the motor driver as well. I chose the overhanging front-most edge to mount mine. I originally used twist ties, but have since then switched to screws. How I did this was by measuring out and drilling two screw holes in the plastic shelf, and then loosely secured the motor driver to the plastic shelf. I will give the pictures of this installation in the next step.

Step 6: Motor Driver Basic Tutorial

The pictures may not be as clear, so I will elaborate on each of the motor driver's 13 pins.

A motor driver is an electronic module that allows the polarity of two terminals to be reversed. When coupled with PWM, H-bridges can control both motor revolution direction, and speed.

What is PWM? (Pulse Width Modulation) PWM is a way of controlling the duration of an electronic pulse. The on-off cycle of the pulse is called a duty cycle. The larger the ratio of on to off results in a faster motor rotation. An analogy of this is found in the every day wind turbine. The quicker the pulse of wind on the turbine, the faster the revolution of the turbine.

There are 13 pins on the motor driver that you need to know:

Out 1: Motor A lead out

Out 2: Motor A lead out

Out 3: Motor B lead out

Out 4: Motor B lead out

5v: 5v input (unnecessary if your power source is 7v-35v, if the power source is 7v-35v then it can act as a 5v out)

GND: For ground. Have all of your grounds tied together; the Arduino, the battery box, and the motor driver.

12V/Power input: The power input. It can actually be from 5v-35v, but is just marked as 12v. The battery box will provide enough power, and the positive terminal of the battery box will go in here.

EnA: Enables PWM signal for Motor A

In1: Enable Motor A

In2: Enable Motor A

In3: Enable Motor B

In4: Enable Motor B

EnB: Enables PWM signal for Motor B

Step 7: Complete Installation and Wiring

This is the big step. Find and secure a location for the Arduino and the ultrasonic sensor. The pictures above show my process for mounting the components.

Now comes the wiring.

*I apologize, my wiring is inconsistent, as I changed it up and the colors many times due to changing circumstances and new discoveries. Resorting to the pictures for the wiring will NOT be clear, except for the Fritzing model above. I am going to write each wiring connection that must be made below as well. These descriptions are the latest, most accurate.*

The wiring is first from the motor driver:

ENA - Arduino digital pin 5

IN1 - Arduino digital pin 6

IN2 - Arduino digital pin 7

IN3 - Arduino digital pin 8

IN4- Arduino digital pin 9

ENB - Arduino digital pin 10

5V - Arduino 5V pin and ultrasonic sensor VCC pin

GND - Battery box negative terminal and Arduino GND. (I inserted the Arduino GND and the battery box negative terminal into the motor driver GND socket, and then tightened the screw carefully.12V - Battery positive pin

Now for the ultrasonic sensor:

GND - Arduino GND

ECHO - Arduino digital pin 4

TRIGGER - Arduino digital pin 3

VCC - Motor driver 5V

Once the wiring is done, pop back on the RC car's exterior if you choose, turn it on and have fun!

Step 8: Programming

I have the code in a file, I couldn't paste the text version so unfortunately you will have to download it. If you need further wiring hints, please read my sketch comments.

Step 9: You're Done!

Congratulations, you're done! If you have any problems or tips, please feel free to share.

The wiring has since been changed, but I have many pictures that document the wiring I used before I changed it, if you wanted to look at them.

*If you enjoyed this Instructable, please vote in the 'Make it Move' or the 'Robotic' contest*

Robotics Contest 2016

Participated in the
Robotics Contest 2016

Make it Move Contest 2016

Participated in the
Make it Move Contest 2016