Use Arduino to Control a Motor Part 4 – Adding a Remote Control and Using Arduino pro Mini for Miniaturization

Use Arduino to Control a Motor Part 4 – Adding a Remote Control and Using Arduino pro Mini for Miniaturization

Arduino Pro Mini RC car with controller

In the last article, we completed the body of the RC car. But, during the building process, we had some issues. Today, we will continue working on the RC car controller. As the Arduino UNO was too large to mount on the car, we will use an Arduino Pro Mini instead.

Today’s Electronics Recipe

Expected time to complete: 90 minutes

Parts needed:

Arduino Pro mini (Arduino Pro Mini 328 5V 16MHz https://www.adafruit.com/products/2378
FTDI-USB Serial converter cable (http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm)
Breadboard (https://www.adafruit.com/products/64)
DC motor (FA-130RA-227 https://www.pololu.com/product/77)
Servomotor (http://www.aliexpress.com/store/product/EMAX-ES3103-17g-Plastic-Analog-Servo/715707_780975050.html)
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 http://www.digikey.com/product-detail/en/1N4007-TP/1N4007-TPMSCT-ND/773694)×2
Resistor 10KΩ×2 / 100KΩ×2
Tact switch
Joystick (https://www.parallax.com/product/27800)
Condenser (100μF http://www.digikey.com/product-detail/en/35ZLH100MEFC6.3X11/1189-1300-ND/3134256)
AA battery box (4 in series)
AA battery×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)

Building the Controller

We will start by making the controller for the RC car.
Last time, we could rotate the car’s wheels left and right and go forward and backward. So, we will build the controller to control these movements. About the program on the Arduino side, we will translate the analog values input via the controller parts into movement.

Today, we will use a tact switch and a joystick as the controller parts.

Switch

Picture 1 Tact Switch

Tact Switch

As you can tell from its name, a tact switch is a type of switch. It makes a clicking sound when you press it, and returns to its original position when you lift your finger. This type of switch is used when we want it to be ON only when it’s being pressed.

Joystick

Picture 2 Joystick

Joystick

The joystick is a well-known part as it’s used to play video games. the joystick is a part consisting of two potentiometers, arranged along the horizontal and vertical axes. When the stick is moved, the potentiometers activate and the resistance changes. On the Arduino, we can determine the state of the joystick based on this change in resistance.

Controller joystick and tact switch

Picture 3 The controller will look something like this

Controller connected to Arduino

Picture 4 Controller

The tact switches will be used for the forward and the backward movement. The joystick will be used for steering left and right. The joystick can be moved along both X and Y axis. Since we are only using it for steering this time, we will only using it on the X axis.
The circuit will look like the following.

Circuit for the controller

Figure 1 Circuit for the controller

To verify the input from the switches and the joystick, we will run a sample program.

The joystick will provide analog input values between 0–1023. For a joystick, the initial value is when the stick is centered along the horizontal dimension (X axis). With our current circuit, the value 512 will be displayed when the joystick is at rest.
For the tact switch, the circuit is complete only when it is pressed, at which point the contents of the if statements are evaluated.

Once we’ve confirmed that the controller is functional, we’ll integrate it with the RC car itself. The circuit will look like the following figure.

RC car circuit

Figure 2 RC car circuit

It’s getting a bit complex and a little confusing at first glance. But it’s built upon components we’re familiar with. So, we only need to be careful about incorrectly connecting the jump wires.

Arduino complete setup for the rc car

Picture 5 The basic setup is complete

The final program will be as follows.

We’ve got to the point where we have the basic functionality of our RC car.
However, it is inconvenient in its current form because the Arduino is too big.
Now, I’d now like to implement several ideas to make the RC car smaller and neater.

Miniaturization with the Arduino Pro Mini

Until now, we have been using Arduino UNO. But it’s too big for the RC car. Hence, today we will work on the miniaturization by using an Arduino Pro Mini.
As I mentioned in the first article, there are different types of Arduino. Today we’ll try out the Arduino Pro mini, which is among the smaller types of Arduino. One word about these compatible boards. As the program to write on the Arduino chips is publicly available, anyone can create his own Arduino by using few components and using a supported chip (such as AVR microcontrollers). Thanks to this, many Arduino boards, compatible with the official versions, are sold. If a board is out of stock, you might want to check something different from the official version. And you can also find something cheaper. It might be worth searching for compatible boards.

Comparison between Arduino UNO and Arduino Pro Mini

Picture 6 Comparison between Arduino UNO (top) and Arduino Pro Mini (bottom)

The major differences between the Arduino UNO and the Arduino Pro mini are the following.

  • Dramatically smaller size
  • Available in 3.3v and 5v operating voltage versions (We’re using the 5v version)
  • The Arduino UNO connects via USB, the Arduino Pro mini connects via serial port
  • Has analog pins 6,7 (absent on the Arduino UNO)

One of the important point is that the Arduino Pro Mini comes in two operating voltage versions.For example, when using a servo that operates at 5v, we can operate it with the 5v Arduino without any external voltage. But, with a 3.3v Arduino, the voltage is insufficient and it won’t run! When using the Arduino Pro mini, we must choose between the 5v or 3.3v version depending on the use case.

It operates in the same way as the Arduino UNO. Only some settings are different, as shown in the following figure.

ToolsMenu

Figure 3 In “Tools” → “Board”, select the Arduino Pro Mini

 

Arduino Serial Port USB

Figure 4 In “Tools”→ “Serial Port”, select serial cable via USB

Once configured, it can be used just like the Arduino UNO. So, we’ll test it out with the LED blinking.

Arduino Pro Mini LED blinking

Picture 7 LED blinking with the Arduino Pro mini

Once the LED blinking is successful, we’ll transfer the RC car circuit that we made on the Arduino UNO to the Arduino Pro mini.
By “transfer”, we only need to reconnect the jump wires according to the pin numbers, so this work is quickly done.

Moving from Arduino UNO to Arduino Pro Mini

Picture 8 We finished the transfer from the Arduino UNO to the Arduino Pro mini

Arduino Pro Mini RC car with controller

Picture 9 Mounting on top of the body

The RC car is now complete!
There are some other ways to make it even lighter and more compact. We can find infinite possibilities, such as replacing the LEGO car body with other parts. Or we could solder the components on the breadboard to a circuit board. As I want to build and RC car using different sensors’ features, I’ll introduce you various type of sensors next time.