Introduction: Arduino Based Robotic Car(wireless Controls+Autonomous)

This instructable is about an Arduino Based Robotic Car which uses Arduino, Arduino programming language, motor driver, a LCD Screen to show the current status of the car and even a Bluetooth module for wireless communication from a smartphone or a laptop.

Step 1: The Parts Required

1. Arduino Uno Development Board

2. L293d IC (motor driver)

3. Two 100 micro Farad Capacitor

4. Four 0.1 micro Farad Capacitor

5. 7812 Voltage Regulator

6. HC-05 Bluetooth Module

7. Jumper Wires

8. Copper Wires

9. Chassis(Body of the car- Can be bought online)

10. Two Wheels

11. One castor wheel(360 degree rotatable wheels)

12. Two 300 RPM Gear Motors.

13. Bread Board

14. Ultrasonic Sensor

15. Regular Batteries(9v)- Short Life / Lithium Ion Batteries- long Life

16. LCD Screen (16x2)

17. Potentiometer

Step 2: Features of the Robotic Car

1. This car can be wirelessly controlled using Bluetooth module and a software Tera Term in case of computer or Blue Term in case of Android smartphones and BT Terminal in case of Windows smartphones.

2. This car can be made both Autonomous and Manually controlled.

3. Due to 300 RPM gear motors this car is comparatively faster than regular Autonomous cars.

4. It also has a LCD screen to display all the current action being taken by the microcontroller.

Step 3: Prerequisites

1. Basic Programming skills.

2. Should know how to use Arduino IDE.

3. Basic knowledge on Electronics.

4. Should know how the connections work in a bread board.

Step 4: Basic Configurations

Coming to the hardware, there are four main parts to be configured:
1. The ultrasonic sensor.

2. The Motor Driver.

3. The LCD.

4. The Bluetooth module.

All these parts are connected to the Arduino Uno and a common 5v and a ground is configured on the bread board using a 5v battery. The power supply is divided into two parts. The first one which is of 5v is connected to the bread board and second one is of 12v which is connected to the motor driver(L293d IC).If the power supply is of different voltages then it can be converted into 5v using 7805 voltage regulator and 12v using 7812 voltage regulator.

Step 5: Connecting Ultrasonic Sensor

The ultrasonic sensor has four pin in which the first one from the left is to be connected to the 5v, the second and third is the trigger and the echo pin which is connected to the Arduino and the forth pin is connected to the ground. The configuration is shown in the diagram above.

Step 6: Connecting Motor Drivers

The L293d IC is the motor driver which is used to control the gear motors. The IC consists of 8 pins each on either sides, due to which two motors can be controlled using a single IC. The configuration is shown in the diagram above.

Step 7: Connecting LCD Screen

The LCD screen used is a 16x2 screen which consists of 16 pins out of which 12 pins are used for the communication. The third pin is connected to the potentiometer which can be of any value. This potentiometer is used to control the brightness of the screen. The configuration is shown in the diagram above.

Step 8: Connecting Bluetooth Module

The Bluetooth module has 6 pins in which only the centre 4 pins are used for the communication. Remember that the TX pin of the module is connected to the RX pin of the Arduino and the RX pin is connected to the TX pin. The Bluetooth module should be connected after the program has been uploaded. Further details are given in the diagram above.

Step 9: Complete Configuration

The final and the complete connections are shown in the diagram above.

Step 10: Functions Used in the Program

The main working of the program is described below:

The program contains 8 functions, namely:

void setup() : All the pin Mode and size of the LCD is defined here.

void loop() : The executes the user's entry that comes through Bluetooth module and calls either

manual() or automatic() for manual and autonomous control.

void manual() : It contains the program to control the robotic car manually by giving various instructions

to the motor driver.

void automatic() : It contains the program for ultrasonic sensor to calculate the distance from the

nearest obstacle and give instructions to the motor driver.

void LCD_start() : All the commands for the LCD which shows up before the robotic car moves in

stored in this function.

void LCD_normal() : All the commands for the LCD which displays on the LCD when there isn't any

obstacle in front of the robotic car is stored in this function.

void LCD_obstacle() : All the commands for the LCD which displays on the LCD when there is a obstacle

in front of the robotic car is stored in this function. void

LCD_final() : All the commands for the LCD which shows up when either of the controls are terminated

is stored in this function.

Step 11: Program/Sketch

#include
#include

LiquidCrystal LCD(10,9,5,4,3,2);

int i;

char j;

//int redled=0;

//int blueled=1;

int trigPin=12;

int echoPin=13;

int left1motor=6;

int left2motor=7;

int right1motor=8;

int right2motor=11;

float pingTime;

float targetDistance;

void setup() {

Serial.begin(9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(left1motor, OUTPUT);

pinMode(left2motor, OUTPUT);

pinMode(right1motor, OUTPUT);

pinMode(right2motor, OUTPUT);

// pinMode(redled, OUTPUT);

// pinMode(blueled, OUTPUT);

LCD.begin(16,2);

LCD_start();

while(!Serial.available());

j=Serial.read();

}

void loop() {

if(j=='a'||j=='A')

{ j='Z';

for(i=0;i<2;i++)

{

LCD.setCursor(0,i);

LCD.print(" ");

}

char displayitem1[]={'A','U','T','O','M','A','T','I','C',' ','C','T','R','L'};

char displayitem2[]={'A','C','T','I','V','A','T','E','D'};

for(i=0;i<14;i++)

{

LCD.setCursor(i,0);

LCD.print(displayitem1[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<9;i++)

{

LCD.setCursor(i,1);

LCD.print(displayitem2[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<3;i++)

{

delay(500);

LCD.setCursor(9,1);

LCD.print(" ");

delay(500);

LCD.setCursor(9,1);

LCD.print("_");

}

automatic();

}

else if(j=='m'||j=='M')

{

j='Z';

for(i=0;i<2;i++)

{

LCD.setCursor(0,i);

LCD.print(" ");

}

char displayitem3[]={'M','A','N','U','A','L',' ','C','O','N','T','R','O','L'};

char displayitem4[]={'A','C','T','I','V','A','T','E','D'};

for(i=0;i<14;i++)

{

LCD.setCursor(i,0);

LCD.print(displayitem3[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<9;i++)

{

LCD.setCursor(i,1);

LCD.print(displayitem4[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<3;i++)

{

delay(500);

LCD.setCursor(9,1);

LCD.print(" ");

delay(500);

LCD.setCursor(9,1);

LCD.print("_");

}

manual();

}

else

{

for(i=0;i<2;i++)

{

LCD.setCursor(0,i);

LCD.print(" ");

}

char displayitem5[]={'W','A','I','T','I','N','G',' ',' ','F','O','R'};

char displayitem6[]={'I','N','S','T','R','U','C','T','I','O','N'};

for(i=0;i<12;i++)

{

LCD.setCursor(i,0);

LCD.print(displayitem5[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<11;i++)

{

LCD.setCursor(i,1);

LCD.print(displayitem6[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<3;i++)

{

delay(500);

LCD.setCursor(11,1);

LCD.print(" ");

delay(500);

LCD.setCursor(11,1);

LCD.print("_");

}

}

while(!Serial.available());

j=Serial.read();

}

void manual()

{

char com;

while(!Serial.available());

g:

com=Serial.read();

if(com=='w'||com=='W')

{

while(!Serial.available())

{

digitalWrite(left1motor, HIGH);

digitalWrite(left2motor, LOW);

digitalWrite(right1motor, HIGH);

digitalWrite(right2motor, LOW);

// LCD_normal();

Serial.println("FORWARD");

}

}

else if(com=='s'||com=='S')

{

while(!Serial.available())

{

digitalWrite(left1motor, LOW);

digitalWrite(left2motor, HIGH);

digitalWrite(right1motor, LOW);

digitalWrite(right2motor, HIGH);

// LCD_normal();

Serial.println("BACKWARD");

}

}

else if(com=='a'||com=='A')

{

while(!Serial.available())

{

digitalWrite(left1motor, LOW);

digitalWrite(left2motor, HIGH);

digitalWrite(right1motor, HIGH);

digitalWrite(right2motor, LOW);

// LCD_obstacle();

Serial.println("LEFT TURN");

}

}

else if(com=='d'||com=='D')

{

while(!Serial.available())

{

digitalWrite(left1motor, HIGH);

digitalWrite(left2motor, LOW);

digitalWrite(right1motor, LOW);

digitalWrite(right2motor, HIGH);

// LCD_obstacle();

Serial.println("RIGHT TURN");

}

}

if(com=='a'||com=='A'||com=='s'||com=='S'||com=='A'||com=='a'||com=='d'||com=='D')

goto g;

else if(com=='e'||com=='E')

{

digitalWrite(left1motor, LOW);

digitalWrite(left2motor, LOW);

digitalWrite(right1motor, LOW);

digitalWrite(right2motor, LOW);

LCD_final();

Serial.println("STOPPED");

}

}

void automatic()

{

g:

while(!Serial.available())

{

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

pingTime = pulseIn(echoPin, HIGH);

pingTime=pingTime/29;

targetDistance=pingTime/2;

// Serial.print("The Distance to Target is: ");

// Serial.print(targetDistance);

// Serial.println(" cm");

// delay(10);

if(targetDistance==0.0)

{

digitalWrite(left1motor, HIGH);

digitalWrite(left2motor, LOW);

digitalWrite(right1motor, HIGH);

digitalWrite(right2motor, LOW);

// LCD_normal();

Serial.println("FORWARD");

}

else if(targetDistance>30.0)

{

digitalWrite(left1motor, HIGH);

digitalWrite(left2motor, LOW);

digitalWrite(right1motor, HIGH);

digitalWrite(right2motor, LOW);

// LCD_normal();

Serial.println("FORWARD");

}

else if(targetDistance<10.0)

{

digitalWrite(left1motor, LOW);

digitalWrite(left2motor, HIGH);

digitalWrite(right1motor, LOW);

digitalWrite(right2motor, HIGH);

// LCD_normal();

Serial.println("BACKWARD");

}

else if(targetDistance<30.0)

{

digitalWrite(left1motor, LOW);

digitalWrite(left2motor, HIGH);

digitalWrite(right1motor, HIGH);

digitalWrite(right2motor, LOW);

LCD_obstacle();

Serial.println("LEFT TURN");

}

}

int com=Serial.read();

if(com!='e'||com!='E')

goto g;

}

void LCD_start()

{

//int i;

LCD.setCursor(0,0);

LCD.print("* WELCOME SIR *");

delay(1000);

LCD.setCursor(0,1);

LCD.print(" PROJECT : ABRC ");

delay(2000);

for(i=0;i<2;i++)

{

LCD.setCursor(0,i);

LCD.print(" ");

}

char displayitem7[]={'C','H','E','C','K','I','N','G',' ','M','O','T','O','R','S'};

char displayitem8[]={'C','O','M','P','L','E','T','E','D'};

for(i=0;i<15;i++)

{

LCD.setCursor(i,0);

LCD.print(displayitem7[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<3;i++)

{

delay(200);

LCD.setCursor(15,0);

LCD.print("_");

delay(200);

LCD.setCursor(15,0);

LCD.print(" ");

}

for(i=0;i<9;i++)

{

LCD.setCursor(i,1);

LCD.print(displayitem8[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<3;i++)

{

delay(500);

LCD.setCursor(9,1);

LCD.print(" ");

delay(500);

LCD.setCursor(9,1);

LCD.print("_");

}

for(i=0;i<2;i++)

{

LCD.setCursor(0,i);

LCD.print(" ");

}

char displayitem9[]={'B','A','S','E','C','O','D','E'};

char displayitem10[]={'U','P','D','A','T','E','D'};

for(i=0;i<8;i++)

{

LCD.setCursor(i,0);

LCD.print(displayitem9[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<3;i++)

{

delay(200);

LCD.setCursor(8,0);

LCD.print("_");

delay(200);

LCD.setCursor(8,0);

LCD.print(" ");

}

for(i=0;i<7;i++)

{

LCD.setCursor(i,1);

LCD.print(displayitem10[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<3;i++)

{

delay(500);

LCD.setCursor(7,1);

LCD.print(" ");

delay(500);

LCD.setCursor(7,1);

LCD.print("_");

}

for(i=0;i<2;i++)

{

LCD.setCursor(0,i);

LCD.print(" ");

}

char displayitem11[]={'I','N','T','I','A','L','I','S','I','N','G'};

char displayitem12[]={'S','E','Q','U','E','N','C','E'};

for(i=0;i<11;i++)

{

LCD.setCursor(i,0);

LCD.print(displayitem11[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<8;i++)

{

LCD.setCursor(i,1);

LCD.print(displayitem12[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<3;i++)

{

delay(500);

LCD.setCursor(8,1);

LCD.print(" ");

delay(500);

LCD.setCursor(8,1);

LCD.print("_");

}

for(i=0;i<2;i++)

{

LCD.setCursor(0,i);

LCD.print(" ");

}

char displayitem5[]={'W','A','I','T','I','N','G',' ',' ','F','O','R'};

char displayitem6[]={'I','N','S','T','R','U','C','T','I','O','N'};

for(i=0;i<12;i++)

{

LCD.setCursor(i,0);

LCD.print(displayitem5[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<11;i++)

{

LCD.setCursor(i,1);

LCD.print(displayitem6[i]);

LCD.print("_");

delay(50);

}

for(i=0;i<3;i++)

{

delay(500);

LCD.setCursor(11,1);

LCD.print(" ");

delay(500);

LCD.setCursor(11,1);

LCD.print("_");

}

}

void LCD_normal()

{

for(i=0;i<2;i++)

{

LCD.setCursor(0,i);

LCD.print(" ");

}

LCD.setCursor(0,0);

LCD.print("ULTRASONIC");

LCD.setCursor(0,1);

LCD.print("INITIATED");

LCD.setCursor(11,0);

LCD.print(targetDistance);

delay(50);

}

void LCD_obstacle()

{

for(i=0;i<2;i++)

{

LCD.setCursor(0,i);

LCD.print(" ");

}

LCD.setCursor(0,0);

LCD.print("OBSTACLE");

LCD.setCursor(0,1);

LCD.print("DETECTED");

LCD.setCursor(11,0);

LCD.print(targetDistance);

delay(100);

}

void LCD_final()

{

LCD.setCursor(0,0);

LCD.print("** THANK YOU **");

delay(1000);

LCD.setCursor(0,1);

LCD.print(" PROJECT : ABRC ");

delay(2000);

for(i=0;i<2;i++)

{

LCD.setCursor(0,i);

LCD.print(" ");

}

}

Step 12: Test Run

Step 13: Thank You for Reading This . Hope You All Liked It.

Robotics Contest

Participated in the
Robotics Contest

Epilog Contest VII

Participated in the
Epilog Contest VII

Tech Contest

Participated in the
Tech Contest