LINE FOLLOWING ROBOT
DESIGN
Design and algorithm
Component List:
- 1 Arduino Uno
- 1 base (where the other components will be fixed)
- 2 wheels
- 2 dc motors (to activate the wheels)
- 1 roller bal (for the rear part to follow front wheels)
- 2 IR transceiver sensors (to detect the line)
DC Motor Driving with IC L293D
As L293D IC has two H-Bridges, each H-Bridge can drive a
DC motor (Max two DC motors can be driven by L293D).
5V for constant speed
Circuit
Digital sensors
// turn left: Left motor stop, Right motor go
// turn right: Left motor go, Right motor stop
Sketch (basic)
void loop() else if(rs==LOW && ls==HIGH)
{ {//right s. Black, Left s. white
int lsPin=2, rsPin=3; //sensor pins rs=digitalRead(rsPin); // turn right
ls=digitalRead(lsPin); digitalWrite(RM1,HIGH);
int ls, rs; //sensor read values
if(rs==HIGH && ls==HIGH) digitalWrite(RM2,HIGH);
int RM1=10, RM2=11, LM1=12, LM2=13; {//both sensors see white digitalWrite(LM1,HIGH);
//Right Motor (RM) and Left Motor (LM) Pins // go straight digitalWrite(LM2,LOW);
digitalWrite(RM1,HIGH); }
void setup()
digitalWrite(RM2,LOW); else if(rs==LOW && ls==LOW)
{ digitalWrite(LM1,HIGH); {//both sensors see black
pinMode(RM1,OUTPUT); digitalWrite(LM2,LOW); // stop
} digitalWrite(RM1,HIGH);
pinMode(RM2,OUTPUT); else if(rs==HIGH && ls==LOW) digitalWrite(RM2,HIGH);
pinMode(LM1,OUTPUT); {//Right s. White, Left s. Black digitalWrite(LM1,HIGH);
pinMode(LM2,OUTPUT); // turn left digitalWrite(LM2,HIGH);
digitalWrite(RM1,HIGH); }
pinMode(lsPin,INPUT); digitalWrite(RM2,LOW);
pinMode(rsPin,INPUT); digitalWrite(LM1,HIGH); delay(100);
digitalWrite(LM2,HIGH); }
}
}