Introduction: Mobile Operated Arduino Uno Robot Using DTMF
Hello,
This is my first instructable. So, I would try to make you understand how to make it. Nowadays, we like to show our friends how intelligent we can be so this is a perfect model you need to make. It is not an autonomous robot but you can call it! But this model also got some serious function as it can improve your knowledge about arduino and programming.Let’s get started!
Step 1: Parts You Need:
· Arduino uno
· DTMF decoder module (SC9270D or MT8870)
· Any mobile (better if android)
· L298N motor driver module
· 1 servo
· 2 DC motors (200 rpm & 5kg/cm torque)
· 3.5 mm audio cable
· 2 wheels
· Chassis
· 3 batteries (9 volts)
· Breadboard
· Double sided tape
· Jumper wires
· castor wheel
Step 2: Assembling the Hardware
Fit those DC motors and castor wheel
in the chassis. Now, take the breadboard and attach arduino Uno,DTMF module & motor driver in a row on it using double sided tape. Finally,attach the breadboard on the chassis.
Step 3: Completing the Circuit
Attach the pin D3,D2,D1,D0 of DTMF
module to digital pin 9,10,11,12 respectively using male to female jumper wires. Attach pin GND & 13 to the power pins on DTMF module.
Remove the ENA & ENB jumper of motor driver and connect them to digital pin 6 and 5 respectively.Attach the pins in1,in2,in3,in4 of motor driver to analog pin A5,A4,A3,A2 respectively.Connect the Out 1(Red) & Out 2(black) pins of motors driver to the right motor and out 3(Red) & out 4(black) to the left motor (when viewed from front).
Attach the signal pin of servo to pin 3 on arduino and +5 volts pin to vin pin & GND to GND on arduino.Attach the audio cable to the DTMF module.
Step 4: Power Solution
Of course! We need a power source to
power our circuit.You can use three 9 volts batteries but they must be connected in parallel otherwise you may fry the board.Or you can use any other power source but it must be of about 9-12 volts.
Connect the GND pin of motor driver to negative terminal of the battery and +12v to the positive terminal of battery.
Now connect the +5v from motor driver to +5v pin on arduino.
Connect GND from motor driver to another GND pin on arduino.
Step 5: Programming the Board
Copy
and paste the programming below to arduino IDE and upload the programming to the board.
#include
Servo myservo;
int servo=3;
int angle=180; // 180 is the initial angle and mobile phone should be placed with camera facing front
int d0=12;
int d1=11;
int d2=10;
int d3=9;
int vccdtmf=13;
int a=0,s=0,d=0,f=0,flag=0;
int in1=19;
int in2=18;
int in3=17;
int in4=16;
int enA=6;
int enB=5;
void setup() {
myservo.attach(3); // Defines Pin 3 for Servo
myservo.write(angle);
pinMode(d0,INPUT);
pinMode(d1,INPUT);
pinMode(d2,INPUT);
pinMode(d3,INPUT);
pinMode(vccdtmf,OUTPUT);
pinMode(in1,OUTPUT);
pinMode(in2,OUTPUT);
pinMode(in3,OUTPUT);
pinMode(in4,OUTPUT);
pinMode(m1,OUTPUT);
pinMode(m2,OUTPUT);
pinMode(servo,OUTPUT); // put your setup code here, to run once:
}
void loop() {
digitalWrite(vccdtmf,HIGH); // +5V for DTMF Module
digitalWrite(enA,HIGH);
digitalWrite(enB,HIGH);
//servo movement//
if(digitalRead(d0)==1 && digitalRead(d1)==1 && digitalRead(d2)==1 && digitalRead(d3)==0) // Press 7 to turn servo in anti-clockwise direction
{
if(angle>0)
{
angle=angle-10;
myservo.write(angle);
delay(500);
}
}
if(digitalRead(d0)==0 && digitalRead(d1)==0 && digitalRead(d2)==0 && digitalRead(d3)==1) // Press 8 to turn servo in clockwise direction
{
if(angle<180)
{
angle=angle+10;
myservo.write(angle);
delay(500);
}
}
while(flag==0) //security loop/////////////////////////////////////////////////////////////////////////////////////////////////////
{
if(a!=1 && digitalRead(d0)==1 && digitalRead(d1)==0 && digitalRead(d2)==0 && digitalRead(d3)==0)
{
a=1;
}
if(a==1 && s!=2 && digitalRead(d0)==0 && digitalRead(d1)==1 && digitalRead(d2)==0 && digitalRead(d3)==0)
{
s=2;
}
if(s==2 && d!=3 && digitalRead(d0)==1 && digitalRead(d1)==1 && digitalRead(d2)==0 && digitalRead(d3)==0)
{
d=3;
}
if(d==3 && f!=4 && digitalRead(d0)==0 && digitalRead(d1)==0 && digitalRead(d2)==1 && digitalRead(d3)==0)
{
f=4;
}
if(a==1 && s==2 && d==3 && f==4)
{
flag=1;
}
} //type 1234 to start operating the robot//1234 works as password//
//movement of car////////////////////////////////////////////////////////////////////////////////
while(digitalRead(d0)==0 && digitalRead(d1)==0 && digitalRead(d2)==1 && digitalRead(d3)==1) // stops the car when pressed #
{
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
}
while(digitalRead(d0)==0 && digitalRead(d1)==1 && digitalRead(d2)==0 && digitalRead(d3)==0) // Press 5 for Forward Direction
{
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
}
while(digitalRead(d0)==1 && digitalRead(d1)==0 && digitalRead(d2)==0 && digitalRead(d3)==0) // Press 4 for Right Forward Direction
{
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
}
while(digitalRead(d0)==1 && digitalRead(d1)==1 && digitalRead(d2)==0 && digitalRead(d3)==0) // Press 6 for Left Forward Direction
{
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
digitalWrite(in3,HIGH);
digitalWrite(in4,LOW);
}
while(digitalRead(d0)==1 && digitalRead(d1)==0 && digitalRead(d2)==1 && digitalRead(d3)==0) // Press 2 for Backward Direction
{
digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);
digitalWrite(in3,LOW);
digitalWrite(in4,HIGH);
}
while(digitalRead(d0)==0 && digitalRead(d1)==0 && digitalRead(d2)==1 && digitalRead(d3)==0) // Press 1 for Right Backward Direction
{
digitalWrite(in1,LOW);
digitalWrite(in2,HIGH);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
}
while(digitalRead(d0)==0 && digitalRead(d1)==1 && digitalRead(d2)==1 && digitalRead(d3)==0) // Press 3 for Left Backward Direction
{
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
digitalWrite(in3,LOW);
digitalWrite(in4,HIGH);
}
}
Step 6: Enjoy Your Robot
Call the phone you have connected to
DTMF module and after receiving the call you have to open keypad and refer to the comments in code for driving manuel.See you next time!!!