Introduction: Smartphone Controlled Arduino Rover

Picture of Smartphone Controlled Arduino Rover

[ Play Video ]

Most of my Instructables are based on renewable energy,battery or recycling used materials.In this Instructable, I have tried something new i.e making a simple Arduino based robot car.This is my first try to make a robot in my life. If you have never tried to make robot, you must be thinking its a difficult hobby to jump into, but the Arduino and the 2WD / 4WD Robot Chassis make it easy for you to build an awesome robot without any struggle.

I always love to share my knowledge learned from my experience.So writing this guide, it will make easy for you to learn the basics of robotics and applications of the Arduino.

Update on 25th Oct 2016

Many people request me to make a tutorial on Obstacle Avoiding Rover.So I made it finally.

You can watch the video.

The code is attached below.

Step 1: Parts and Tools Required

Picture of Parts and Tools Required

Parts :

1. 4WD Robot Chassis kit ( GearBest)

2. Arduino Nano (GearBest )

3. LM298 H bridge Module (GearBest)

4. Bluetooth Module HC-06 ( Amazon )

5. 2 x 18650 Li Ion Battery ( Gear Best )

6. 2x 18650 Battery Holder ( Gear Best )

7. Mini Bread Board ( Gear Best )

8. 0.5 sqmm Wires

9. Male-Female Jumper Wires ( Amazon )

10. Male-Male Jumper Wires ( Amazon )

11. Duct Tape or any other tape ( Amazon )

For Obstacle Avoiding Robot :

HC - SR04 Ultrasonic Distance Measuring Module ( GearBest )

Tools Required :

1. Soldering Iron ( Amazon )

2. Wire Cutter ( Amazon )

3. Wire Stripper ( Gear Best )

4.Glue Gun ( GearBest )

Step 2: What Is a Robot ?

Robot is an electromechanical device which is capable of reacting in some way to its environment, and take autonomous decisions or actions in order to achieve a specific task.

A robot is consists of following components

1. Structure / Chassis

2. Actuator / Motor

3. Controller

4. Inputs / Sensors

5. Power Supply

In the next steps I will describe each of the above components, so that you can understand easily.

Step 3: Structure / Chassis

Picture of Structure / Chassis

The structure consists of physical components. A robot has one or more physical components that move in some way to perform the task.In our case the Chassis and wheels are the structure of the robot.

Step 4: Actuator

Picture of Actuator

An “actuator” can be defined as a device that converts energy (in robotics, that energy tends to be electrical) into physical motion. Most of the actuators produce either rotational or linear motion.

In our case the actuator is DC gear motor.It is basically a DC motor combined with a gearbox that works to decrease the motor’s speed and increase the torque.

Example : A DC motor having speed 3000 rpm and torque 0.002 N•m . Now we add a gear to it with gear ratio 1:48.The new speed is reduce by a factor 48 ( resulting 3000/44 = 68 rpm ) and the torque increased by a factor of 48.( resulting 0.002 x 48 = 0.096 N.m.

Step 5: Prepare the Motors Terminal

Picture of Prepare the Motors Terminal

Cut 4 pieces of red and black wires with length approximately 5 to 6 inch.I was using 0.5 sqmm wires.

Strip out the insulation from the wires at each end

Solder the wires to the motor terminal.

You can check the motor polarity by connecting it to the battery pack.If it rotates in forward direction ( red wire with positive and black wire with negative terminal of the battery) then the connection is ok.

Step 6: Mount the Motor

Picture of Mount the Motor

[ Assembling Video ]

Attach the two acrylic fastener to each motor using two long bolts and two nuts.You can watch the assembling video to know the details.

Note that the wires on each motor are pointing toward the centre of the chassis.

Join the two red wires and black wires of the motor on each side of the chassis.

So after joining, you have two terminals on left side and two terminal on right side.

Step 7: Install the Top Roof

Picture of Install the Top Roof

After mounting the 4 motors on the bottom floor , you have to mount trhe top roof.

Mount the 6 copper stand off by using the M3 nuts

Pull out the terminal wires towards the top roof.

Step 8: Controller

Picture of Controller

Now the robot chassis and actuator are added but controller is missing.Chassis without controller means nothing will happen. Your robot will sit in one place.Its just like a human without life.

So a controller ( brain ) is needed to move the robot from one place to another.It is a computing device capable of executing a program and is responsible for all computations, decision making, and communications.In our case, we are using an Arduino Nano microcontroller as a Controller.

The controller takes input ( sensors, Remote etc ) , process it and then gives a command to the actuator ( motor ) to do the desired task.

If you take a battery hook the positive side to one side of your DC motor. Then you connect the negative side of the battery to the other motor lead. The motor spins forward. If you swap the battery leads the motor spins in reverse. You can use your microcontroller to rotate the motor in one direction.But if you want to be able to control the motor in both forward and reverse with your microcontroller, you will need more circuitry. You will need an H-Bridge

In the next step I will explain what exactly H-bridge is.

Step 9: H Bridge ( LM 298 Module )

Picture of H Bridge ( LM 298 Module )

What is H- Bridge ?

The term H bridge is derived from the typical graphical representation of such a circuit .It is a circuit which can drive a DC motor in forward and reverse direction.

Working : See the above picture for understanding the working of the H bridge.It is consists of 4 electronics switches S1,S2,S3 and S4 ( Transistors / MOSFETs/ IGBTS ).

When the switches S1 and S4 are closed (and S2 and S3 are open) a positive voltage will be applied across the motor.So it rotates in the forward direction.Similarly when S2 and S3 are closed and S1 and S4 are opened a reverse voltage is applied across the motor, so rotates in revers direction.

Note : The switches in the same arm ( either S1,S2 or S3,S4) are never closed at a same time, it will make a dead short circuit.

H bridges are available as integrated circuits, or you can built your own by using 4transistors or MOSFETs.

In our case we are using LM298 H-bridge IC that can allows to control the speed and direction of the motors.

Pin Description :

Out 1: DC motor 1 "+" or stepper motor A+

Out 2: DC motor 1 "-" or stepper motor A-

Out 3: DC motor 2 "+" or stepper motor B+

Out 4: Motor B lead out

12v :12V input but you can use 7 to 35V

GND: Ground

5v: 5V output if 12V jumper in place, ideal for powering your Arduino (etc)

EnA: Enables PWM signal for Motor A (Please see the "Arduino Sketch Considerations" section)

IN1: Enable Motor A

IN2: Enable MotorA

IN3: Enable MotorB

IN4: Enable MotorB

BEnB: Enables PWM signal for Motor B (Please see the "Arduino Sketch Considerations" section)

Step 10: Input / Sensors

Picture of Input / Sensors

Unlike humans, robots are not limited to just sight, sound, touch, smell and taste. Robots use different sensors to

interact with the external world.

A sensor is a device that detects and responds to some type of input from the physical environment. The specific input could be light, heat, motion, moisture, pressure, or any one of a great number of other environmental phenomena.

The inputs may be from sensors,Remote or Smartphone.

In this basic tutorial I am using Smartphone as a input device to control the Rover.

Step 11: Power Source

Picture of Power Source

A robot needs a power source to drive the actuators ( motors ) and the controller. Most of the robots are powered by a battery.When we talk about battery, there are lot of options

1. AA Alkaline Battery ( Non Rechargeable )

2. AA NiMh or NiCd Battery ( Rechargeable )

3. Li Ion Battery

4. LiPo Battery

So according to the requirement choose the suitable one.In my opinion, always choose a rechargeable and sufficient capacity battery.I used 2nos of 2600mAh LiIon Battery ( 18650 Samsung Brand ).If you need more power for autonomy you can choose a large battery pack like 5A turnigy.

Battery Holder :

The battery holder that I am using is ordered from china.It is not suitable for flat top battery like Samsung. So I attached two neodymium magnets on the positive terminal of the battery to fit perfectly.

Charging :

You need a good charger to charge the battery pack.As per my experience these are few good chargers

1.PowerEx AA Charger-Analyzer ( Amazon )

2. XTAR LiIon Battery Charger ( Amazon )

3. Turnigy LiPo Battery Charger ( Amazon )

Step 12: Mount the Components

Picture of Mount the Components

On the top roof mount the entire circuit.

I used hot glue to mount the Battery Holder, Motor Driver (LM 298 ) and Mini Bread Board.You can also screw it.

Mount the Bluetooth module by using duct tape.

Insert the Arduino Nano on to the mini bread board.

Step 13: Electrical Wiring

Picture of Electrical Wiring

For wiring you need some jumper wires.

Connect the red wires of two motors ( on each side )together and black wires together.So finally you have two terminals in each side.

MOTORA is in charge of two right side motors, correspondingly two left side motors are connected to MOTORB

Follow the instruction below to connect everything.

Motors Connection:

Out1 -> Left Side Motor Red Wire (+ )

Out2 -> Left Side Motor Black Wire ( - )

Out3 -> Right Side Motor Red Wire ( + )

Out4 -> Right Side Motor Black Wire ( - )

LM298 - > Arduino

IN1 -> D5

IN2-> D6

IN2 ->D9

IN2-> D10

Bluetooth Module -> Arduino

Rx-> Tx

Tx ->Rx

GND -> GND

Vcc -> 3.3V

Power

12V - > Connect Battery Red Wire

GND -> Connect Battery Black wire and Arduino GND pin

5V -> Connect to Arduino 5V pin

Step 14: Control Logic

Picture of Control Logic

To understand the working, I made this logic table.It is very useful during writing of the code.

Step 15: Software

Picture of Software

The software part is very simple,it does not need any library.If you understand the logic table in the earlier steps then you can write you own code. I didn't spend much time on writing the code, so just using a code written by someone else.To control the Robot Car, I am using my smartphone.The smartphone is connected to the controller via a Bluetooth module ( HC -06)

Download the App

After installing the app, you have to pair it with the Bluetooth module.The password for pairing is " 1234 ".

Arduino code is attached below.

Step 16: Testing

Picture of Testing

To test the Robot Car, I placed it on a cardboard box.So that the wheels will rotate but not move.

Then check it by pressing the all keys.

If all the functions work perfectly, then its ready for actual operation.

Note : If the motors are rotate in wrong directions, just swap the wires.

Step 17: Future Plan

Picture of Future Plan

In this guide I have explained how to make a simple Rover .Now the next task is to add more features in it.

You can add different sensors according to the requirements. These are some ideas to be implemented in future

1. Adding Ultrasonic Ping Sensors for obstacle avoiding

2. Using WiFi Module like ESP8266 or Node MCU instead of Bluetooth for long range control.

3. Adding a solar panel for charging the battery pack

If you enjoyed this article, don’t forget to pass it along!

Follow me for more DIY projects and ideas. Thank you !!!

Comments

funshanas (author)2017-12-11

If I disconnect Arduino USB cable from my PC, mobile commands to control the robot stop working. What is the reason behind it? Please guide me.

georgekw (author)2017-12-10

Can you help in HC-SR04 on a car with microbit and kitronik board

georgekw (author)2017-12-10

Very inspiring

RamavtarK (author)2017-12-10

Can Bluetooth module hC-05 can be used instead of Hc06

amrus2011 (author)RamavtarK2017-12-10

We used the HC SR-04. I think the HC SR-05 has 5 pins instead of 4 because of the Bluetooth capabilities. If you use the 05, do not connect the 4th pin to anything. Connect GND to pin 5. If you use pin 4 as GND, I think it will act like the 3 pin version. If you have not bought the sensor yet, just use the HC SR-04. It works just fine. Which ever one you use, be sure you have downloaded the library for that component. Good luck with your build.

BittuK4 (author)2017-12-10

sir can you give circuit diagram

amrus2011 made it! (author)2017-04-28

My 5th grade class made two of the obstacle avoidance robot cars and they work perfectly. Very exciting. Thanks for a great instructable.

Arobinda dey (author)amrus20112017-08-30

Plz send me the code... behappy.rimon@gmail.com plz sir

deba168 (author)Arobinda dey2017-09-01

Download the code from step-15.I have attached the file in .pdf as wll as .ino format.

RamavtarK (author)deba1682017-12-09

Can I use HC-05 instead Hc-
06

VinayakkK (author)amrus20112017-11-24

can you please help from overcome the problem facing after the uploading program in my nano but the motors cant work when i press the forword or any button on my bluetooth app

amrus2011 (author)VinayakkK2017-12-02

I'm afraid I can't help you with your problem. We did not build that version. Ours was the obstacle avoidance model. We did not use a remote control or a smart phone to control our cars. They ran on their own, uncontrolled. You are going to have to upload the code for the smart phone version that uses Bluetooth. I hope you get it working.

aadeshborate5 (author)amrus20112017-07-26

Please send me the code

deba168 (author)aadeshborate52017-09-01

Download the code from step-15.I have attached the file in .pdf as wll as .ino format.

amrus2011 (author)aadeshborate52017-07-26

Unfortunately the actual code is on my computer at school and since we on summer holiday now, it will be the 1st of September before I will have access to it. However I did find this on one of my flash drives. I'm not sure if this is the correct code that's on my school computer, but what have you got to lose, right? I hope it works for you. Let me know either way yes or no.

//
Arduino Obstacle Avoiding Robot

//
Code adapted from http://www.educ8s.tv

//
First Include the NewPing and Servo Libraries

#include
<NewPing.h>

#include
<Servo.h>

#define
TRIG_PIN A4

#define
ECHO_PIN A5

#define
MAX_DISTANCE 200

NewPing
sonar(TRIG_PIN, ECHO_PIN, MAX_DISTANCE);

Servo
myservo;

boolean
goesForward=false;

int
distance = 100;

int
speedSet = 0;

const
int motorPin1 = 11;

const
int motorPin2 = 10;

//Motor
B

const
int motorPin3 = 6;

const
int motorPin4 = 5;

void
setup() {

myservo.attach(9);

myservo.write(115);

delay(2000);

distance = readPing();

delay(100);

distance
= readPing();

delay(100);

distance
= readPing();

delay(100);

distance
= readPing();

delay(100);

}

void
loop() {

int
distanceR = 0;

int
distanceL = 0;

delay(40);

if(distance<=20)

{

moveStop();

delay(100);

moveBackward();

delay(300);

moveStop();

delay(200);

distanceR
= lookRight();

delay(200);

distanceL
= lookLeft();

delay(200);

if(distanceR>=distanceL)

{

turnRight();

moveStop();

}else

{

turnLeft();

moveStop();

}

}else

{

moveForward();

}

distance
= readPing();

}

int
lookRight()

{

myservo.write(50);

delay(500);

int
distance = readPing();

delay(100);

myservo.write(115);

return
distance;

}

int
lookLeft()

{

myservo.write(170);

delay(500);

int
distance = readPing();

delay(100);

myservo.write(115);

return
distance;

delay(100);

}

int
readPing() {

delay(70);

int
cm = sonar.ping_cm();

if(cm==0)

{

cm
= 250;

}

return
cm;

}

void
moveStop() {

analogWrite(motorPin1,
0);

analogWrite(motorPin2,
0);

analogWrite(motorPin3,
0);

analogWrite(motorPin4,
0);

}

void
moveForward() {

analogWrite(motorPin1,
180);

analogWrite(motorPin2,
0);

analogWrite(motorPin3,
180);

analogWrite(motorPin4,
0);

}

void
moveBackward() {

analogWrite(motorPin1, 0);

analogWrite(motorPin2,
180);

analogWrite(motorPin3,
0);

analogWrite(motorPin4,
180);

}

void
turnRight() {

analogWrite(motorPin1,
180);

analogWrite(motorPin2,
0);

analogWrite(motorPin3,
0);

analogWrite(motorPin4,
180);

delay(300);

moveForward();

}

void
turnLeft() {

analogWrite(motorPin1,
0);

analogWrite(motorPin2,
180);

analogWrite(motorPin3,
180);

analogWrite(motorPin4,
0);

delay(300);

moveForward();

}

AlanL45 made it! (author)2017-09-01

Are you able to post the code for the blue tooth project without the distance sensor ? I've done the robot.... Many thanks,

deba168 (author)AlanL452017-09-01

Congratulation !

Thanks for sharing the pics.

Download the code from step-15.I have attached the file in .pdf as wll as .ino format.

VinayakkK (author)deba1682017-11-24

sir i made my all project but there is a problem when i run my motors but all the sensors are working fine sir please help me
how my motors work

gk2010 (author)2017-11-09

hi, i just finished the rc car and uploaded the code but when i go to run it through the phone only the wheels on the right of the car work. The forward button, reverse, right, and left only work on the wheels on the right side. Any help?? It's for a project in one of my classes.

gk2010 (author)2017-11-09

hi, i just finished the rc car and uploaded the code but when i go to run it through the phone only the wheels on the right of the car work. The forward button, reverse, right, and left only work on the wheels on the right side. Any help?? It's for a project in one of my classes.

MichaelO256 (author)2017-11-04

Hi.

I like the design but I have had a consistent problem. The battery pack alone will not deliver power to the bluetooth module. It needs the usb to be connected. In reverse, the usb does not supply power to the motors.

When both the usb and the batteries are connected everything works. Any thoughts?

FilipT20 (author)2017-10-17

I have 1 big problem. When I want to verify the code for the Arduino Board it give me this error:

Arduino: 1.8.2 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Users\Filip\Documents\Arduino\libraries\FW5VI90IUOHMPMB\FW5VI90IUOHMPMB.ino:7:21: fatal error: NewPing.h: No such file or directory

#include <NewPing.h>

^

compilation terminated.

exit status 1

Error compiling for board Arduino/Genuino Uno.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

What should I do to go everything well?

farmerkeith (author)FilipT202017-10-29

It seems to me that you do not have the NewPing.h library installed.

You can get it here

http://playground.arduino.cc/Code/NewPing

or here

https://github.com/PaulStoffregen/NewPing

I have not used these myself, but this looks like your problem to me.

DiegoC231 (author)2017-10-17

Do you have the code but without the obstacle sensor?

athulajayghosh (author)2017-10-12

Bro i made the car but when i connect to bluetooth and press any key then it shows "unable to write broken pipe.please help athulajayghosh@gmail.com

mamun87 (author)2017-10-11

hello sir
my project is all most done thanks for your video but when i play using phone an error mesaage is showing" unable to write broken pipe". my project is not working please help me where is my mistake. please help as soon as possible.
thanks
mamun420spi@gmail.com

mamun87 (author)2017-10-11

sir i have some problem all things are done but on phone showing "unable to write broken pipe". can not understan why it is happening please help as soon as possible. mamun420spi@gmail.com
please

SpS7 (author)2017-10-05

Can I use this

SpS7 (author)2017-10-05

Can I use a BLUETOOTH TRANSCEIVER mobule HC 05

PRITHVIA3 (author)2017-09-21

camers can be used

Devang Dileep (author)2017-09-18

Hello!

I made it

I put 4 AA battery but it does not work

How much voltage it needs to work

9 volt battery is enough

FazeelH (author)2016-12-04

Arduino: 1.6.12 (Windows 8.1), Board: "Arduino Nano, ATmega328"

Sketch uses 2,594 bytes (8%) of program storage space. Maximum is 30,720 bytes.

Global variables use 188 bytes (9%) of dynamic memory, leaving 1,860 bytes for local variables. Maximum is 2,048 bytes.

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x49

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x49

avrdude: stk500_recv(): programmer is not responding

Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#up... for suggestions.

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x49

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x49

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x49

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x49

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x49

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x49

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x49

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x49

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

Having this error continuously when uploading the code.
solution asap.
using arduino nano.

Mahir_Asef (author)FazeelH2017-09-16

same problem

NazMars4395 (author)2017-09-14

can I run the code on Arduino mega 2560? should I change to use same pin on Arduino 2560?

sanskar kakde (author)2017-05-26

please send me code to sanskarkakde13@Gmail.com

deba168 (author)sanskar kakde2017-09-01

Download the code from step-15.I have attached the file in .pdf as wll as .ino format.

DevanshV2 (author)2017-05-28

Please send me the code to:devansh.verma20@gmail.com

deba168 (author)DevanshV22017-09-01

Download the code from step-15.I have attached the file in .pdf as wll as .ino format.

Manku vs raja (author)2017-06-05

Bro send a code my gmail add.

09rajathakur@gmail.com

deba168 (author)Manku vs raja2017-09-01

Download the code from step-15.I have attached the file in .pdf as wll as .ino format.

HarshdeepS8 (author)2017-06-17

Plzz send me code singhharshdeep687@gmail.com

DhruvA14 (author)HarshdeepS82017-06-18

did u get the code?

deba168 (author)DhruvA142017-09-01

Download the code from step-15.I have attached the file in .pdf as wll as .ino format.

HarshdeepS8 (author)DhruvA142017-06-18

No bro

deba168 (author)HarshdeepS82017-09-01

Download the code from step-15.I have attached the file in .pdf as wll as .ino format.

Arobinda dey (author)2017-08-30

My dear sir pls send me the code... My email id is =behappy.rimon@gmail.com

MachvelleP (author)2017-08-28

i connected all wiring correctly but both wheel at one side not moving using smartphone control , when i use avoidance code works fine

AlanL45 (author)2017-08-27

Great tutorial. Very clear. Would really like the code. Please help us with this request. Thanks.

aadeshborate5 (author)2017-07-26

Please send me the code on
aadeshborate5@gmail.com

aadeshborate5 (author)2017-07-26

Can anybody send me the code
aadeshborate5@gmail.com

About This Instructable

161,014views

410favorites

License:

Bio: I am an Electrical Engineer.I love to harvest Solar Energy and make things by recycling old stuffs. I believe &quot;&quot;IF YOU TRY YOU MIGHT ... More »
More by deba168:DIY Professional 18650 Battery PackDIY Acrylic RGB LED SignHow to Make a Bench Power Supply
Add instructable to: