In this blog you learn how to make Line follower robot using two IR sensor’s .
In line follower robot, IR sensors follow the black path or black line when IR signals are emitted by the sensor and reflected back by the surface to the receiver, but in black path, IR signals won’t be reflected because black color absorbs all signals.
Follow these following steps >>
Components and software required. >>

- Arduino uno
- Two IR sensor
- A robotic car chassis
- Two BO Motor with wheels
- L293D module
- A ball caster wheel
- Arduino IDE software in a operating system
Step 1 :- Assemble all the components
Attach BO Motor in chassis and screw tightly >>

Attach wheels in motor >> To attach ball caster wheel use dual tape

Your Chassis assembly is complete
Step2:- Connect L293D motor driver module

Attach +VE and -VE Terminal in identical side of motor driver >>

Step 3:- Connect IR sensor in a long strip cardboard

Better use dual tape to attach IR sensors and more components
Step 4:- Now connect components according to circuit diagram

Attach every component on Chassis

Better use different power supply for Motor driver and Arduino uno for best performance >>
You can attach 9v battery to Arduino and 9v – 12v battery to motor driver
Now time to upload code to Arduino UNO
Step 5:- Install Arduino IDE Download through link below >>
https://www.arduino.cc/en/donate/

click on just download
Step 6 :- Upload code to Arduino IDE
// www.elconics.com
int sen1=A0;
int sen2=A1;
int val1,val2;
int m1=8,m2=9,m3=10,m4=11;
char dir;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(sen1,INPUT);
pinMode(sen2,INPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(m1,OUTPUT);
pinMode(m2,OUTPUT);
pinMode(m3,OUTPUT);
pinMode(m4,OUTPUT);
}
void loop() {
digitalWrite(2,HIGH); // SEN2 VCC GET CONNECTED IN GPIO PIN 2 AND GND PIN IN 3
digitalWrite(3,LOW);
digitalWrite(4,HIGH); // SEN2 VCC GET CONNECTED IN GPIO PIN 4 AND GND PIN IN 5
digitalWrite(5,LOW);
// put your main code here, to run repeatedly:
val1=analogRead(sen1);
val2=analogRead(sen2);
Serial.print("SENSOR 1 VALUE = ");
Serial.println(val1);
Serial.print("SENSOR 2 VALUE = ");
Serial.println(val2);
delay(200);
if (val1<200 && val2 <200)
{
dir= 'F';
}
else if (val1>800 && val2 >800)
{
dir= 'S';
}
else if (val1>800 && val2 <200)
{
dir= 'R';
}
else if (val1<200 && val2 >800)
{
dir= 'L';
}
else if (val1>200 && val2 >800)
{
dir= 'L';
}
switch(dir)
{
case 'F' :
digitalWrite(m1,HIGH);
digitalWrite(m2,LOW);
digitalWrite(m3,HIGH);
digitalWrite(m4,LOW);
break;
case 'R' :
digitalWrite(m1,HIGH);
digitalWrite(m2,LOW);
digitalWrite(m3,LOW);
digitalWrite(m4,HIGH);
break;
case 'L' :
digitalWrite(m1,LOW);
digitalWrite(m2,HIGH);
digitalWrite(m3,HIGH);
digitalWrite(m4,LOW);
break;
case'S' :
digitalWrite(m1,LOW);
digitalWrite(m2,LOW);
digitalWrite(m3,LOW);
digitalWrite(m4,LOW);
break;
}
}
Congratulations You are done now Connect battery and place in black path
Checkout this Video how to assemble components .