Arduino:How to make a RC car with arduino
MULTI FEATURED ROBOT WITH ARDUINO
This robot was mainly built for understanding Arduino and combining various projects of Arduino to form a Multi Featured Arduino Robot. And further, who doesn't want to have a pet robot? So I named it BLUE ROVIER 316. I could have bought a beautiful tracked chassis but making it from scratch teaches you more and gives you more pride after you have completed it.
The robot is capable of understanding voice commands, answering simple questions, controlling as an RC car and even avoiding obstacles while moving. It is mainly controlled through an Android phone which is connected to it through Bluetooth. Based on Android features such as Google Voice Recognition and Tilt sensing, it can really behave like a cute, smart robot. I added BLUE in its name because it is mainly based on Bluetooth. It was actually my first Arduino project and I wanted it to be unique .
If you like the project, please do vote for me in the Robotics Contest !
You will need just the following components:
1. Android system
2. Arduino Uno
3. wtv020-sd-16p module and 8ohm speaker
4. 2x L293d motor controller circuit
5. 4x bo motors and wheels
6. HC SR04 ultrasonic sensor
7. 9g servo
8. 8 AA battery holder and batteries
9. 1gb micro SD card
10. small switch box for chassis.
11. HC 05 Bluetooth Module
I know it looks costly! But don't worry, it will only cost about two or three thousand rupees. Talking about the Android, it won't be a great issue to posses one because most have it nowadays. But having newer versions (above 5.0) might increase the performance.
Try to buy motors having moderate rpm (60 to 100). This would help to keep the speed of the robot under control, as no other speed control circuit is installed. And 8 aa batteries are enough to power the robot for a good time. And considering the Bluetooth, HC 05 is suitable for the robot because it is cheap enough, and the performance is outstanding too.
The 1 GB micro SD card is needed to store voice files which are played when any question is asked to the robot [ Discussed in detail in the later part of the intstructable ]. The other components are discussed in detail in their respective step.
Now let's move onto some simple "Theories" that are used in this robot.
The robot is capable of understanding voice commands, answering simple questions, controlling as an RC car and even avoiding obstacles while moving. It is mainly controlled through an Android phone which is connected to it through Bluetooth. Based on Android features such as Google Voice Recognition and Tilt sensing, it can really behave like a cute, smart robot. I added BLUE in its name because it is mainly based on Bluetooth. It was actually my first Arduino project and I wanted it to be unique .
If you like the project, please do vote for me in the Robotics Contest !
1. Android system
2. Arduino Uno
3. wtv020-sd-16p module and 8ohm speaker
4. 2x L293d motor controller circuit
5. 4x bo motors and wheels
6. HC SR04 ultrasonic sensor
7. 9g servo
8. 8 AA battery holder and batteries
9. 1gb micro SD card
10. small switch box for chassis.
11. HC 05 Bluetooth Module
I know it looks costly! But don't worry, it will only cost about two or three thousand rupees. Talking about the Android, it won't be a great issue to posses one because most have it nowadays. But having newer versions (above 5.0) might increase the performance.
Try to buy motors having moderate rpm (60 to 100). This would help to keep the speed of the robot under control, as no other speed control circuit is installed. And 8 aa batteries are enough to power the robot for a good time. And considering the Bluetooth, HC 05 is suitable for the robot because it is cheap enough, and the performance is outstanding too.
The 1 GB micro SD card is needed to store voice files which are played when any question is asked to the robot [ Discussed in detail in the later part of the intstructable ]. The other components are discussed in detail in their respective step.
Voice Control
The robot can understand voice commands through an android phone. I guess everyone is familiar with Google Voice Recognition, the feature in Android where we say the word and Google types it.
The same feature is used here for recognising voice commands and converting them into text commands. The app here converts speech to text through Google and sends it to the robot through Bluetooth. The robot is programmed to follow these commands received through Bluetooth. It is also capable of answering a good number of questions. You can even add some more commands in the code to make the robot do some more awesome things.
The same feature is used here for recognising voice commands and converting them into text commands. The app here converts speech to text through Google and sends it to the robot through Bluetooth. The robot is programmed to follow these commands received through Bluetooth. It is also capable of answering a good number of questions. You can even add some more commands in the code to make the robot do some more awesome things.
Gesture Control
The gesture control or motion control mode is also done through the Android. In this mode, the robot can be controlled as an RC car by using the Android as the steering wheel. There is a sensor called "Accelerometer" in all Androids which is used in this mode. This accelerometer can determine the angle at which the phone is titled by measuring the acceleration forces acting on the Android. It is this sensor that makes the Android rotate its screen when we tilt the phone. The app here uses the phone accelerometer to determine the angle at which the phone is tilted. Then a character (A, B....) is sent to the robot through Bluetooth. The arduino is programmed to work according to the data received.
If the phone is tilted ahead, character A is sent and robot moves forward. When tilted back, character B is sent and the robot moves backward and so on for left and right. When the Android is placed horizontally, the character E is sent and the robot stops moving.
If the phone is tilted ahead, character A is sent and robot moves forward. When tilted back, character B is sent and the robot moves backward and so on for left and right. When the Android is placed horizontally, the character E is sent and the robot stops moving.
Bluetooth Control
In this mode,the robot works as a general RC car. Nothing new in this mode, it is just the same as a general remote controlled car available in the market, the only difference being that we are using an Android app to control the robot.
There are different buttons in the app, each having different characters associated with it. When any key is touched, a character is sent to the robot through Bluetooth, just like the gesture control mode. Further, the same characters are sent when the respective keys are touched, and the robot follows the incoming characters.
I have used the 360 and -360 degree buttons in the app to make the robot look right and left. You can change it in the code if you want to make the robot do some other things.
There are different buttons in the app, each having different characters associated with it. When any key is touched, a character is sent to the robot through Bluetooth, just like the gesture control mode. Further, the same characters are sent when the respective keys are touched, and the robot follows the incoming characters.
I have used the 360 and -360 degree buttons in the app to make the robot look right and left. You can change it in the code if you want to make the robot do some other things.
Obstacle Avoidance
Making the chassis on your own, you must be very careful about the measurements and alignments. I chose to do so because I couldn't find one on the net that satisfied me.
A general switch box used for power supply purposes is being used as the chassis. I guess, you can easily get one from an electrical appliance store. Firstly, attach the four motors at the bottom with some glue or clamps and then attach the wheels. Then you have to make the head of the robot (the servo and HC SR04 sensor).For the head, cut a small piece of perfboard and attach it to the servo through a screw. Then attach the ultrasonic sensor to the perfboard with some glue. Cut a small square hole at the top of the box and fix the servo in it.
Then attach the battery holder at the back of the robot through a screw. Put the circuits and the other components inside the box and your chassis is ready. Don't forget to make some holes in front of the speaker for the sound to come out and produce a better quality.
A general switch box used for power supply purposes is being used as the chassis. I guess, you can easily get one from an electrical appliance store. Firstly, attach the four motors at the bottom with some glue or clamps and then attach the wheels. Then you have to make the head of the robot (the servo and HC SR04 sensor).For the head, cut a small piece of perfboard and attach it to the servo through a screw. Then attach the ultrasonic sensor to the perfboard with some glue. Cut a small square hole at the top of the box and fix the servo in it.
Then attach the battery holder at the back of the robot through a screw. Put the circuits and the other components inside the box and your chassis is ready. Don't forget to make some holes in front of the speaker for the sound to come out and produce a better quality.
Voice Module
The speaking mode of the robot is fulfilled by the WTV 020 SD module. The module is used to play voice files for the robot. When any question is asked, the arduino will make the module play the respective voice file in the SD card. There are four serial data lines on the module for communicating with the arduino, the reset, clock, data and busy pins.
Remember that the names of the files should be in decimal (0001, 0002...). And that the files should either be in AD4 or WAV format. Further the module works only on a 1gb micro SD card. Some modules even work on 2gb cards and the card can hold a maximum of 504 voice files. So you can include a good number of voice files to play for a good number of questions.
You can even make your own voice AD4 files ( You can skip this part if you can adjust with the voice files provided along with this intstructable ).
Firstly, you must have two softwares, a sound editing software and a software called 4D SOMO TOOL which would convert the files to the AD4 format. Secondly, you have to prepare the Robot Voices. You can either convert text to speech or even record your own voice and make the Robot voices. Both of these can be done in the Sound Editing Software. But surely, robots do not look good if they speak human voices. So it should be better to convert text to speech. There are various engines like Microsoft Anna and Microsoft Sam your Computer that would help to do this.
After preparing the voice files, you have to save it in 32000 Hz and in the WAV Format. This is because the module can play voice files upto 32000 Hz. Then use the 4D SOMO TOOL to convert the files to the AD4 format. To do so, just open the SOMO TOOL, select the files, and click AD4 Encode and your voice files are ready. You can check the picture above for reference.
Remember that the names of the files should be in decimal (0001, 0002...). And that the files should either be in AD4 or WAV format. Further the module works only on a 1gb micro SD card. Some modules even work on 2gb cards and the card can hold a maximum of 504 voice files. So you can include a good number of voice files to play for a good number of questions.
You can even make your own voice AD4 files ( You can skip this part if you can adjust with the voice files provided along with this intstructable ).
Firstly, you must have two softwares, a sound editing software and a software called 4D SOMO TOOL which would convert the files to the AD4 format. Secondly, you have to prepare the Robot Voices. You can either convert text to speech or even record your own voice and make the Robot voices. Both of these can be done in the Sound Editing Software. But surely, robots do not look good if they speak human voices. So it should be better to convert text to speech. There are various engines like Microsoft Anna and Microsoft Sam your Computer that would help to do this.
After preparing the voice files, you have to save it in 32000 Hz and in the WAV Format. This is because the module can play voice files upto 32000 Hz. Then use the 4D SOMO TOOL to convert the files to the AD4 format. To do so, just open the SOMO TOOL, select the files, and click AD4 Encode and your voice files are ready. You can check the picture above for reference.
Short all the Vcc pins of the respective modules together and connect it to the 5v pin on the arduino. Do the same for gnd pins.
Here are the connections of the different modules.
HC 05 module:
RX pin to arduino dig pin 0.
TX pin to arduino dig pin 1.
HC SR04 sensor:
Echo pin to arduino dig pin 6.
Trig pin to arduino dig pin 7
WTV020-SD module:
pin1 (reset pin) to arduino dig pin2.
pin4 to speaker +
pin5 to speaker -
pin7 (clock) to arduino dig pin3.
pin8 to gnd.
pin10 (data) to arduino dig pin4.
pin15 (busy) to arduino dig pin5.
pin16 to 3.3v
Then, connect the servo signal (yellow) wire and to dig pin 12.
L293d motor controller:
pin A1 to arduino dig pin 8.
pin A2 to arduino dig pin 9.
pin B1 to arduino dig pin 10.
pin B2 to arduino dig pin 11.
Remember that in this robot, we are using two L293d modules. This is because one module has the capacity to power up to two motors. In order to control four motors, we are using two motor drivers. So do remember to make duplicate connections on both the motor controller modules. For e.g connect the Arduino pin 8 to pin A1 of both the driver modules. Do not forget to connect the output of one module on two motors and the other module onto the other two motors.
Check the diagram for further reference.
Here are the connections of the different modules.
HC 05 module:
RX pin to arduino dig pin 0.
TX pin to arduino dig pin 1.
HC SR04 sensor:
Echo pin to arduino dig pin 6.
Trig pin to arduino dig pin 7
WTV020-SD module:
pin1 (reset pin) to arduino dig pin2.
pin4 to speaker +
pin5 to speaker -
pin7 (clock) to arduino dig pin3.
pin8 to gnd.
pin10 (data) to arduino dig pin4.
pin15 (busy) to arduino dig pin5.
pin16 to 3.3v
Then, connect the servo signal (yellow) wire and to dig pin 12.
L293d motor controller:
pin A1 to arduino dig pin 8.
pin A2 to arduino dig pin 9.
pin B1 to arduino dig pin 10.
pin B2 to arduino dig pin 11.
Remember that in this robot, we are using two L293d modules. This is because one module has the capacity to power up to two motors. In order to control four motors, we are using two motor drivers. So do remember to make duplicate connections on both the motor controller modules. For e.g connect the Arduino pin 8 to pin A1 of both the driver modules. Do not forget to connect the output of one module on two motors and the other module onto the other two motors.
Check the diagram for further reference.
Arduino Code
It was an exciting time making the code. It is not a complicated code at all, it just uses some libraries to communicate with the Android and the sound module. A major part of the work is done in the Android and not in the Arduino. The code is based on Bluetooth communication and the incoming data from the Bluetooth. The code is made in such a way that we have to give voice commands to the robot to execute the different modes and the Arduino continuously checks for incoming Bluetooth Signals. To stop any mode, we just have to say "stop".
The only problem with the code is that we have to manually switch off the robot when it is in the Obstacle Avoidance Mode. We cannot use the "stop" command in this mode. This is because setting this feature on affects the speed of scanning the distance of the objects. The Arduino will have to read simultaneously both the distance of an object as well as the incoming Bluetooth signals. This interferes the mode and the robot fails to protect itself fully from obstacles. The robot might fail to stop instantly even if the distance ahead is less than 30 cm. So it would be good not to include this feature in this mode.
Just download the libraries and the code and Upload it to the Arduino. But do not forget to take out the TX and RX (0, 1) pins from the Arduino before uploading. These pins are used for Serial communication and are in use during the uploading of the code. And in this robot, these pins are used for connecting the Bluetooth module. So do remember to take them off else it might hamper your Bluetooth Module.
The only problem with the code is that we have to manually switch off the robot when it is in the Obstacle Avoidance Mode. We cannot use the "stop" command in this mode. This is because setting this feature on affects the speed of scanning the distance of the objects. The Arduino will have to read simultaneously both the distance of an object as well as the incoming Bluetooth signals. This interferes the mode and the robot fails to protect itself fully from obstacles. The robot might fail to stop instantly even if the distance ahead is less than 30 cm. So it would be good not to include this feature in this mode.
Just download the libraries and the code and Upload it to the Arduino. But do not forget to take out the TX and RX (0, 1) pins from the Arduino before uploading. These pins are used for Serial communication and are in use during the uploading of the code. And in this robot, these pins are used for connecting the Bluetooth module. So do remember to take them off else it might hamper your Bluetooth Module.
#include <Servo.h>
#include <SoftwareSerial.h>
#include <Wtv020sd16p.h>
#include <Ultrasonic.h>
int mA1 = 8;
int mA2 = 9;
int mB1 = 10;
int mB2 = 11;
int reset = 2;
int clock = 3;
int data = 4;
int busy = 5;
int leftLook;
int rightLook;
int distance;
String voice;
Wtv020sd16p wtv020sd16p(reset, clock, data, busy);//create an object wtv020sd16p(sound module)
SoftwareSerial BT(0, 1); //TX and RX respectively
Servo myservo; //create a servo object
Ultrasonic ultrasonic(6, 7); //Trigger and Echo respectively
void setup() {
pinMode(mA1, OUTPUT);//Set the motor pins as output
pinMode(mA2, OUTPUT);
pinMode(mB1, OUTPUT);
pinMode(mB2, OUTPUT);
myservo.attach(12);//Attaches the servo on pin 12
BT.begin(9600);
Serial.begin(9600);//Start a serial communication
wtv020sd16p.reset();//Reset the module
servofunction();
delay(500);//delay added to make things prominent
wtv020sd16p.playVoice(0);//Say hello to everyone
}
void loop() {
while (BT.available()) {// Check for incoming Serial Data over Bluetooth
delay(10);//Delay added to make things stable
char c = BT.read();//Conduct a Serial Bluetooth read
voice += c;//Build the Strings
}
if (voice.length() > 0) {//If any Serial data is available
Serial.println(voice);//Print the data on the serial monitor
{
// Answering General Questions
if (voice == "*what is your name#" ) {
wtv020sd16p.playVoice(1);
}
else if (voice == "*what is your phone number#")
{ wtv020sd16p.playVoice(2);
}
else if (voice == "*how old are you#")
{ wtv020sd16p.playVoice(3);
}
else if (voice == "*are you married#")
{ wtv020sd16p.playVoice(4);
}
else if (voice == "*do you like games#")
{ wtv020sd16p.playVoice(5);
}
else if (voice == "*how are you#")
{ wtv020sd16p.playVoice(6);
}
else if (voice == "*what do you like to do#")
{ wtv020sd16p.playVoice(7);
}
else if (voice == "*can you play any game#")
{ wtv020sd16p.playVoice(8);
}
else if (voice == "*can you think#")
{ wtv020sd16p.playVoice(9);
}
else if (voice == "*what can you do#")
{ wtv020sd16p.playVoice(10);
}
else if (voice == "*do you have any friends#")
{ wtv020sd16p.playVoice(11);
}
else if (voice == "*introduce yourself#") {
wtv020sd16p.playVoice(12);
}
else if (voice == "*which language can you speak#")
{ wtv020sd16p.playVoice(13);
}
else if (voice == "*can you speak any other language#")
{ wtv020sd16p.playVoice(14);
}
else if (voice == "*what do you like to eat#")
{ wtv020sd16p.playVoice(15);
}
else if (voice == "*can you dance#") {
wtv020sd16p.playVoice(16);
}
else if (voice == "*can you sing#") {
wtv020sd16p.playVoice(16);
}
else if (voice == "*hello#") {
wtv020sd16p.playVoice(17);
}
else if (voice == "*which sport do you like#") {
wtv020sd16p.playVoice(18);
}
// Physical Activities
else if (voice == "*look left#") {
myservo.write(180);
}
else if (voice == "*look right#") {
myservo.write(0);
}
else if (voice == "*look ahead#") {
myservo.write(90);
}
else if (voice == "*turn front#") {
myservo.write(90);
}
else if (voice == "*go forward#") {
forward();
delay(700);
stop();
}
else if (voice == "A") {
forward();
}
else if (voice == "*go back#") {
backward();
delay(700);
stop();
}
else if (voice == "B") {
backward();
}
else if (voice == "*turn left#") {
myservo.write(180);
delay(500);
myservo.write(90);
delay(400);
left();
delay(750);
stop();
}
else if (voice == "C") {
left();
}
else if (voice == "G") {//look left
myservo.write(180);
}
else if (voice == "*turn right#") {
myservo.write(0);
delay(500);
myservo.write(90);
delay(400);
right();
delay(750);
stop();
}
else if (voice == "D") {
right();
}
else if (voice == "F") {//look right
myservo.write(0);
}
else if (voice == "*stop#") {
stop();
wtv020sd16p.reset();
myservo.write(90);
}
else if (voice == "E") {
stop();
myservo.write(90);
}
// Performing Activities
while (voice == "*avoid the obstacles#") {// Obstacle avoidance mode
obstacleavoidance();
}
}
voice = "";//Reset the variable
}
}//SKYLARK SYSTEM
//Version 30.11.18
// Functions
void servofunction() {
myservo.write(180);
delay(500);
myservo.write(90);
delay(500);
myservo.write(0);
delay(500);
myservo.write(90);
}
void forward() {
digitalWrite(mA1, HIGH);
digitalWrite(mA2, LOW);
digitalWrite(mB1, HIGH);
digitalWrite(mB2, LOW);
}
void backward() {
digitalWrite(mA1, LOW);
digitalWrite(mA2, HIGH);
digitalWrite(mB1, LOW);
digitalWrite(mB2, HIGH);
}
void right() {
digitalWrite(mA1, HIGH);
digitalWrite(mA2, LOW);
digitalWrite(mB1, LOW);
digitalWrite(mB2, HIGH);
}
void left() {
digitalWrite(mA1, LOW);
digitalWrite(mA2, HIGH);
digitalWrite(mB1, HIGH);
digitalWrite(mB2, LOW);
}
void stop() {
digitalWrite(mA1, LOW);
digitalWrite(mA2, LOW);
digitalWrite(mB1, LOW);
digitalWrite(mB2, LOW);
}
void obstacleavoidance() {
distance = ultrasonic.Ranging(CM); // (Use CM for centimeter and INC for inches)
delay (50);// check for objects
if (distance > 30) {
forward();
}
else if (distance <= 30) {
backward();// Act as a brake
stop(); //Object detected
delay(500);
distances(); // Proceed to the next function
}
}
void distances() {
myservo.write(180);//take distances from the left side
delay(350);
leftLook = ultrasonic.Ranging(CM);
myservo.write(90);
delay(500);
myservo.write(0);//take distances from the right side
delay(350);
rightLook = ultrasonic.Ranging(CM);
myservo.write(90);
delay(40);
comparison();
}
void comparison() {
if (leftLook > rightLook) {
left();
delay(750);
obstacleavoidance();
}
else if (leftLook < rightLook) {
right();
delay(750);
obstacleavoidance();
}
else if (leftLook < 15 && rightLook < 15) {
backward();
delay(350);
stop();
distances();
Many problems arise in the WTV-020-SD-16p module, regarding the capacity of the memory card. This is because some modules work on 2 GB cards while some do not. So it is better to use a 1 GB micro SD card.
There would not be much problem in using different versions of the components. Mention may be made of the different versions of the wtv 020 sd module. This is because there exists only packaging difference between the modules, while most of the other internal things remain the same.
Another important thing, using a PCB for the robot will help in reducing current consumption to a great extent. If you are connecting the different components just like me, it would cost you some current because a good amount of it will be lost in the wires, having a high resistance. This is because the circuit is quite big enough. This intstructable does not include the designing of a PCB ( because I did not make one) but it can increase the power efficiency of the robot.
But BLUE ROVIER 316 is not done yet! I thought of including some more features such as following lines, solving mazes and many other things. But it remained a dream because of the lack of pins on the Arduino UNO ( BLUE ROVIER really eats many pins of the Arduino). So I think of improving all the features of this robot and combine them together to form a more sophisticated and useful Arduino Robot. So be ready to see the modified view of ROVIER in a few months!!!
I even wish to see other modified versions of the robot by some other people possessing more creativity than mine!!!!
There would not be much problem in using different versions of the components. Mention may be made of the different versions of the wtv 020 sd module. This is because there exists only packaging difference between the modules, while most of the other internal things remain the same.
Another important thing, using a PCB for the robot will help in reducing current consumption to a great extent. If you are connecting the different components just like me, it would cost you some current because a good amount of it will be lost in the wires, having a high resistance. This is because the circuit is quite big enough. This intstructable does not include the designing of a PCB ( because I did not make one) but it can increase the power efficiency of the robot.
But BLUE ROVIER 316 is not done yet! I thought of including some more features such as following lines, solving mazes and many other things. But it remained a dream because of the lack of pins on the Arduino UNO ( BLUE ROVIER really eats many pins of the Arduino). So I think of improving all the features of this robot and combine them together to form a more sophisticated and useful Arduino Robot. So be ready to see the modified view of ROVIER in a few months!!!
I even wish to see other modified versions of the robot by some other people possessing more creativity than mine!!!!
Comments
Post a Comment