In the article “Use Arduino to Control a Motor Part 2“, we went over how to use a motor driver. Today, we will look at the motor driver in more detail and make our own radio-controlled car using a motor driver.
Just like when we made the Stevenson Screen, we will decide the specs of the radio-controlled car before getting started.
Expected time to complete: 90 minutes
Arduino (Arduino Uno R3)
Arduino Pro mini (Arduino Pro Mini 328 5V 16MHz)
DC motor (FA-130RA-227)
Motor driver (BD6222HFP http://www.digikey.com/product-detail/en/BD6222HFP-TR/BD6222HFPCT-ND/1936319)
SOP16 pin DIP adapter board https://www.sparkfun.com/products/498
Diode (1N4007) ×2 http://www.digikey.com/product-detail/en/1N4007-TP/1N4007-TPMSCT-ND/773694
Resistor 10KΩ×2 / 100KΩ×2
Condenser (100μF http://www.digikey.com/product-detail/en/35ZLH100MEFC6.3X11/1189-1300-ND/3134256)
Box for AA batteries (series circuit for 4)
AA batteries x 4
Toggle switch (http://www.amazon.com/250V-Position-Micro-Toggle-Switch/dp/B014XJ7PZG)
LEGO blocks – as necessary
8T pinion gear http://www.amazon.com/15289-Mini-Metal-Plastic-Pinion/dp/B002CAT2TG
Today, we will try to make the basic parts of an RC car by ourselves and study basics about electronic circuits, steering, and engine movements.
Figure 1: Structure of a radio-controlled car
Figure 1 shows a rough breakdown of the functions found in an RC car. In other words, if you fulfill these functions, you can call it an RC car.
We will go over how all these parts work and how to customize them using actual demonstrations.
Before we get started, let’s decide the overall specs for the RC car. Here is an overview.
That looks about right.
Now, let’s see what kind of technology we need to use to make these things possible…
Let’s get started. First, we will design the heart of an RC car, the circuit for “Basic movements are forward, backward, and steering mount.”
Going forward and backward using a motor driver
We went over forward/backward motor movement in the article “Use Arduino to Control a Motor Part 2”. We will use the same circuit today.
Figure 2: DC motor circuit
In the circuit in figure 2 (see article “Use Arduino to Control a Motor Part 2“), we can rotate and reverse the motor by outputting signals from Arduino #9 and #10, one after the other. We can use the same idea to make the RC car go forward and backward.
Let’s think about mounting the steering to make the car turn left and right.
If we use a DC motor, can we make it turn by 30 degrees to the right? Maybe we should rotate the motor for just a little bit and move the motor 30 degrees? Sounds pretty difficult. That’s where the servo motor comes in.
A servo motor is like the other motors we’ve used before with an additional circuit that controls angles.
Pic 1: Servo motor
The servo motor we will be using today can control the angle from 0 to 180.
Let’s create a circuit to control the servo motor. When using a servo motor with Arduino, there is a library of useful materials (set program with pre-made process). We will control the servo motor using this servo library.
Pic 2: Controlling a servo motor with Arduino
Figure 3: Arduino circuit for servo motor
// Program for moving servo motor
#include <Servo.h> //Reading servo motor library
Servo myservo; //Create an object for the servo
int val; //Variable for storing servo angle
myservo.attach(9); //Set digital pin 9 as the command pin for determining the servo angle
val = 0;
myservo.write(val); //Move the servo (0 degree)
val = 90;
myservo.write(val); //Move the servo (90 degrees)
Once we finish the steering control, we will combine it with the drive shaft circuit.
Here, the servo is set to digital 11, and the DC motor control is set to digital 9 and 10.
Figure 4: Arduino circuit for servo motor and DC motor
#include <Servo.h> //Read library for servo motor
Servo myservo; //Create an object for servo
int val; // Variable for storing servo angle
myservo.attach(11); // Set the digital pin 11 as the command pin for determining the servo angle
val = 0;
val = 45;
In this example, we set the delay at (1500), so the steering and driveshaft will move every 1.5 seconds. Next, let’s make it so that we can control it based on the input from the controller.
Now that we have the circuit ready and that we are able to control the angle of the motor with a servo motor, let’s create the steering for the car.
I’d like to say, “We’re going to make a realistic one using a 3D printer!”, but at this point that is too difficult. Let’s think about what we need for a steering system and try them out. So, today, let’s use LEGO blocks to fulfill “The body should be easy to build”.
If you search “LEGO steering”, there are many pages showing how to mount a LEGO steering. Today, we want to keep it as small as possible, so here is what we made.
Pic 2: Steering setup
Pic 3: Steering parts (left: backside/right: without tires)
The steering part is done, so let’s go into the drive shaft. This is a DC motor, but there was an article about making a motor and a LEGO gear by yourself using a Pinion gear from Mini-4WD, so we will use this method to connect the motor with a LEGO gear.
If you have a LEGO motor, that may work too. We want to keep the motor as small as possible, so let’s keep trying!
Pic 4: Setting the pinion gear onto the LEGO gear
The motor and driveshaft can be connected directly. Our priority is making something that works, so we are using rubber bands to fix the motor.
It looks like you can add transmission, or prioritize speed/torque by changing gear ratio, so customize them to your liking!
Pic 5: A simple drive shaft
Now, let’s combine the steering with the drive shaft.
Pic 7: Mounting the Arduino on the top of it
Putting the Arduino directly on top looks good! But the batteries for the motor and the circuit breadboard won’t fit…
Once we finish the circuit and body, we will test it out and give it a test run.
Pic 8: Testing the circuits
The steering and the drive shaft are moving properly. So now we have the basic parts of a radio-controlled car. We’ve come this far, so let’s mount the Arduino and other things onto the body.
Pic 9: Putting everything on the body of the car
It looks cool uncovered! But it looks a bit bumpy…
We tried to pack everything onto the body, but it’s just not enough coverage. Plus, the Arduino gets too big compared to the body. Moreover, there is no space for 9V batteries to power the Arduino. Making it lighter seems essential.
In our next article, we will create a controller and try to control the motor using controller inputs. Also, the Arduino and the breadboard are still too big and heavy, so we will try out a smaller Arduino like the Arduino Pro Mini.
Pic 10: Arduino UNO and Arduino Pro Mini (conversion board)