Serial Communication :- Serial Communication is the Process of Sending one bit of data at a time, sequentially over the communication channel or Computer bus.
Computer Controlled Robot :-
Component Required :-
Computer Controlled Robot :-
Component Required :-
- 2 -Motors
- Motor Driver
- Arduino uno
- Wheels
- PC
Project Objectives
Fig :-Circuit Diagram
Connect the Circuit diagram as shown in Figure.
Connect the Controller Pin from Motor Driver to 6,7,8,9 pin of Arduino.
Connect the power pin of Motor driver to 5V and GND of Arduino.
Connect the Motor to the Motor Driver as shown in Figure.
Now Arrange the circuit in the Chasis and Connect the motor with Wheels.
Code
int lm1=6;
int lm2=7;
int rm1=8;
int rm2=9;
void setup() {
// put your setup code here, to run once:
pinMode(lm1,OUTPUT);
pinMode(lm2,OUTPUT);
pinMode(rm1,OUTPUT);
pinMode(rm2,OUTPUT);
Serial.begin(9600);
Serial.println("press \n forward 8 \n backward 2 \n left 4 \n right 6 \n stop others pin");
}
void loop() {
// put your main code here, to run repeatedly:
while(Serial.available()==0);
int val= Serial.read()-'0';
if(val==8)
{
digitalWrite(lm1,HIGH);
digitalWrite(lm2,LOW);
digitalWrite(rm1,HIGH);
digitalWrite(rm2,LOW);
Serial.println(" \n now moving forward");
}
else if(val==2)
{
digitalWrite(lm1,LOW);
digitalWrite(lm2,HIGH);
digitalWrite(rm1,LOW);
digitalWrite(rm2,HIGH);
Serial.println(" \n now moving backward");
}
else if(val==4)
{
digitalWrite(lm1,HIGH);
digitalWrite(lm2,LOW);
digitalWrite(rm1,LOW);
digitalWrite(rm2,HIGH);
Serial.println(" \n now moving left");
}
else if(val==6)
{
digitalWrite(lm1,LOW);
digitalWrite(lm2,HIGH);
digitalWrite(rm1,HIGH);
digitalWrite(rm2,LOW);
Serial.println("\n now moving right");
}
else
{
digitalWrite(lm1,LOW);
digitalWrite(lm2,LOW);
digitalWrite(rm1,LOW);
digitalWrite(rm2,LOW);
Serial.println(" \n now stop");
}
Serial.flush();
}
Now upload the Code and open the Serial monitor .
Press 8 :- Robot Moves Forwards
Press 2 :- Robot Moves Backwards
Press 4 :- Robot moves in left direction
Press 6 :- Robot Moves in Right direction