logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Arduino

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

Device Plus Editorial Team
Published by Device Plus Editorial Team at January 8, 2016
Categories
  • Arduino
Tags
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)
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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//*******************************************
// Controller Sample Program
//*******************************************
int aPin = 2;
int bPin = 4;
int cPin = A2;
void setup() {
Serial.begin(9600);
Serial.println("setup");
pinMode(aPin,INPUT);
pinMode(bPin,INPUT);
}
void loop() {
Serial.print("JOYSTICK:");
Serial.println(analogRead(A2));
if(digitalRead(aPin) == HIGH){
Serial.println("A");
}
if(digitalRead(bPin) == HIGH){
Serial.println("B");
}
delay(100);
}

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <Servo.h>  // Load servo motor library
Servo myservo; // Create an object for the servo
int val; // Variable to store servo angle
int aPin = 2;
int bPin = 4;
int cPin = 9;
int dPin = 10;
void setup() {
myservo.attach(11); // Set digital pin 11 as output pin for servo angle commands
Serial.begin(9600);
Serial.println("setup");
pinMode(aPin,INPUT);
pinMode(bPin,INPUT);
pinMode(cPin,OUTPUT);
pinMode(dPin,OUTPUT);
}
void loop() {
int st = analogRead(A2); // 0-1023, center is 512
float st2 = (float)st/1023;
val = st2*90;
val = val+45;
myservo.write(val); //Move servo based on joystick value
Serial.print("SERVO:");
Serial.print(st2);
Serial.print("-");
Serial.println(val);
if(digitalRead(aPin) == HIGH){
Serial.println("A");
digitalWrite(cPin,HIGH);
digitalWrite(dPin,LOW);
}
else if(digitalRead(bPin) == HIGH){
Serial.println("B");
digitalWrite(cPin,LOW);
digitalWrite(dPin,HIGH);
}
else{
digitalWrite(cPin,LOW);
digitalWrite(dPin,LOW);
}
delay(100);
}

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.

Device Plus Editorial Team
Device Plus Editorial Team
Device Plus is for everyone who loves electronics and mechatronics.

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • Use Arduino to Control a Motor Part 3 – Making an RC Car Using a Servo Motor for the SteeringUse Arduino to Control a Motor Part 3 – Making an RC Car Using a Servo Motor for the Steering
  • From Electric Skateboards to Drones: 5 DIY Projects To Hone Your Electronics SkillsFrom Electric Skateboards to Drones: 5 DIY Projects To Hone Your Electronics Skills
  • Use Arduino to Control a Motor Part 1 – Motor BasicsUse Arduino to Control a Motor Part 1 – Motor Basics
  • Use Arduino to Control a Motor Part 2 – Motor DriverUse Arduino to Control a Motor Part 2 – Motor Driver
  • Using Arduino with Parts and Sensors – Accelerometer Part 2Using Arduino with Parts and Sensors – Accelerometer Part 2
  • How To Make Your Own RobotHow To Make Your Own Robot
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort