Introduction: How to Make a Wired Rc Car Using an Arduino

I am going to show you how to make an RC car with an arduino

Step 1: Materials

2 Arduino unos (that's just what I used.)

Jumper wires and Male to Female Wires

2 Arduino joysticks

2 9v batteries

1 9.6v rechargeable RC car battery

1 Tower Pro Servo

1 Seeed Studio motorsheild

4 wheels

2-4 axles or something to mount the wheels so they can spin freely

Something to use as a base

A long cable with enough wires to connect to both of your joysticks

A soldering iron with solder

Some way to mount all this. I would suggest Velcro for the arduinos and hot glue for the servo and mounting the wheels. I just used rubber bands.

2-4 DC motors to power the wheels.

2 9v to Arduino plugs.

Step 2: Step 2: Preparing the Base and Wheels

First, take your 2-4 DC motors and solder two jumper wires to each copper lead.Take whatever it is that you are using for your base and cut a hole into it that will be big enough to fit your servo into. Hot glue your servo into place. Then, take your axle and hot glue it to your servo. This will act as your steering. Have the wires from the servo come up from underneath the base. After that, glue the other axle on the other side of your base, also on the bottom.

Second, take one arduino and your Seeed Studio Motorshield and connect that to the arduino. After that is all done, take your 9.6v battery and use rubber bands to keep it in place on the bottom of your base. Then, take your arduinos and put velcro on the bottoms of both and then velcro on the top of your base.

Step 3: Step 3: Wiring

The Servo:

Start off by wiring your regular arduino. Take 2 wires, 1 should be a male to female wire, and plug 1 end into both of the arduinos 5v input. Take 2 more wires and plug one end into both of the arduinos Ground inputs. Now take 2 more wires and plug one end of one wire into Analog 0 and the one end of another wire and plug that into PIN 9. Now, take a male to female wire plugged into Analog 0, and plug it into the joystick pin that is labeled vrY. Next, plug the female end of the wire coming from the 5v into the 5v on the joystick. Next, take a male to female wire plugged into the Ground input on the arduino, and plug the female end into the Ground on the joystick. Now, take the wire plugged into pin 9 and plug it into the yellow wire.(or the lightest colored wire, it is different on some servos). Now, take the wire plugged into the 5v pin on the arduino and plug that wire into the second lightest colored wire. Now, take the final wire plugged into the Ground pin on the arduino and plug it into the darkest colored wire onthe servo. That should now be done.

The Motors:

Start by taking all of the wires from the motors and plugging them into the 4 motor ports on the Seeed studio MotorShield. Now do the same wiring you did on the servo joystick. The only thing that will be different if that you want to plug the Analog 0 into the vrX PIN on the joystick. The rest is the same.

Step 4: Step 3: the Servo Code

On the servo code, I changed the servo from turning 180 degrees, to 45 degrees. This is so when the servo is turned all the way to the right or left, the wheel is not just dragging behind the RC car.

Servo Code:

Controlling a servo position using a potentiometer (variable resistor) by Michal Rinott

modified on 8 Nov 2013 by Scott Fitzgerald */


Servo myservo; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin

void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object }

void loop() { val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) val = map(val, 0, 1023,0, 45); // scale it to use it with the servo (value between 0 and 180) myservo.write(val); // sets the servo position according to the scaled value delay(15); // waits for the servo to get there }

Step 5: Step 4: the Motor Code

On the motor code, I added 1 motor to the code so it can run 2 motors at once. If you want to get rid of this, take out everything that says int pinI3=12; int pinI4=13;

int speedpinB=10; pinMode(pinI3,OUTPUT); pinMode(pinI4,OUTPUT); pinMode(speedpinB,OUTPUT);

and digitalWrite(pinI4,LOW); digitalWrite(pinI3,HIGH);

Motor Code:

#include "MotorDriver.h"

const int POT_PIN = A0; const int POT_PIN2 = A1; int motorSpeed = 0; int potVal = 0; int pinI1=8;//define I1 interface int pinI2=11;//define I2 interface int pinI3=12; int pinI4=13; int speedpinA=9;//enable motor A int speedpinB=10;

void setup() { Serial.begin(9600); TCCR1B = TCCR1B & 0b11111000 | 0x01; pinMode(pinI1,OUTPUT); pinMode(pinI2,OUTPUT); pinMode(pinI3,OUTPUT); pinMode(pinI4,OUTPUT); pinMode(speedpinA,OUTPUT); pinMode(speedpinB,OUTPUT);


void loop() { potVal = analogRead(POT_PIN); potVal = analogRead(POT_PIN2);

motorSpeed = map(potVal, 0, 1023, 0, 255);

Serial.print(potVal); Serial.print(motorSpeed); Serial.println();

analogWrite(speedpinA, motorSpeed); analogWrite(speedpinB, motorSpeed); digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise digitalWrite(pinI1,HIGH); digitalWrite(pinI4,LOW); digitalWrite(pinI3,HIGH);


Arduino All The Things! Contest

Participated in the
Arduino All The Things! Contest