Arduino Based Line Tracker Robot

by aishwarya.arora.35 in Circuits > Microcontrollers

30398 Views, 27 Favorites, 0 Comments

Arduino Based Line Tracker Robot

DSC_0058.jpg
DSC_0061~3~2.jpg
DSC_0061.jpg

Line trackers are one of the most prominent kinds of robot. they have been existed for very long time and usually for beginners in robotics this is the best project you can play with since this robot has some basic functions and basic programming.

A line tracker robot is a robot able to detect and track a line (black) even if the path is altered by changing the shape of the line. this type of robot has a simple task, and doesn't require strong skills in programming and electronics.

STUFF REQUIRED:

arduino.jpg
5 sensor.jpg
l293d-dual-dc-motor-driver-ic.jpg
chassis.png
BREADBOARD.png
PCB.jpg
motor.png
castor.png
sumowheels.jpg
BATTERY.jpg
BATT.png
WIRES.png

HARDWARE:

  • Arduino Uno
  • 1x IR Sensor Module
  • 1x L293D Motor Driver IC
  • Robotic Platform / Chassis
  • Breadboard / PCB ( It's up to you )
  • 2x DC Motors
  • 1x Castor Wheel
  • 2x Wheels
  • 1x 12V Battery
  • 1x 9V Battery
  • And finally some connecting wires

SOFTWARE:

  • Arduino IDE : ARDUINO

HOW IT WORKS:

block diag.png

The robot has five infrared sensor module attached at the front of our robot that detects from where the light reflects back. that information is used to decide whether to continue straight or to change the direction of the motors to turn accordingly.

Working of line tracker is very simple and interesting. line tracker senses black line by using sensor module and then sends the signal to arduino. then arduino drives the motor according to the sensors' output.

FUNDAMENTAL LOGIC OF LINE TRACKER:

A Dark object reflects less light than a bright object, or we can also say, a dark object absorbs more light than a bright object, this is the only fundamental logic behind a line tracking robot. so, in a line tracking robot, we use a sensor that detects the difference between bright and dark objects, or simply, distinguishes a black line from a white surface.


MAKING CONNECTIONS AND ASSEMBLING THE ROBOT:

ardiuno labelled.png
l293d.jpg
RobotTracker2-250.jpg
DSC_0014.jpg
DSC_0015.jpg
DSC_0016.jpg
DSC_0017.jpg
DSC_0019.jpg
DSC_0020.jpg
DSC_0935_1478380946961.jpg
DSC_0936_1478380939541.jpg
DSC_0021.jpg
DSC_0022.jpg
DSC_0024.jpg
DSC_0939_1478380922261.jpg
DSC_0942_1478380918215.jpg
DSC_0943_1478380901207.jpg

Look over your robotic platform / chassis and decide how you would like to assemble it. It's all up to you, either you can make an open and exposed version of your line tracker using breadboard connections or you can go with an enclosed and sorted wiring style like I did using PCB. However, I preferrd to choose enclosed and sorted version for my line tracker and tried to give a unique and different look to my line tracker robot.

I have also made a motor driver shield which is directly connected to the arduino uno board as per the connections ( shown in above figures ).


Make the connections as follows:

  • ARDUINO VCC - SENSOR MODULE VCC
  • ARDUINO GND - SENSOR MODULE GND
  • ARDUINO DIGITAL PIN 12 - SENSOR MODULE S1
  • ARDUINO DIGITAL PIN 11 - SENSOR MODULE S2
  • ARDUINO DIGITAL PIN 10 - SENSOR MODULE S3
  • ARDUINO DIGITAL PIN 9 - SENSOR MODULE S4
  • ARDUINO DIGITAL PIN 8 - SENSOR MODULE S5

And connections for motor driver is shown in above figure.

ARDUINO PROGRAMMING:

Screenshot (130).png

Upload the given code to your Arduino Uno board and get ready for the ACTION !

#define lmotorf 4 //Motor A1
#define lmotorb 5 //Motor A2 #define rmotorf 6 //Motor B1 #define rmotorb 7 //Motor B2

//HIGH white //LOW black

void setup() { pinMode(lmotorf,OUTPUT); pinMode(rmotorf,OUTPUT); pinMode(lmotorb,OUTPUT); pinMode(rmotorb,OUTPUT); pinMode(8,INPUT); pinMode(9,INPUT); pinMode(10,INPUT); pinMode(11,INPUT); pinMode(12,INPUT); pinMode(13,INPUT); }

void loop() {

int sensor1=digitalRead(8);//sensor1 int sensor2=digitalRead(9);//sensor2 int sensor3=digitalRead(10);//sensor3 int sensor4=digitalRead(11);//sensor4 int sensor5=digitalRead(12);//sensor5

if((sensor2==LOW)&&(sensor3==LOW)&&(sensor4==LOW)) //When ALL ARE on WHITE line {

digitalWrite(lmotorf,HIGH); digitalWrite(rmotorf,HIGH); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); } else if((sensor2==HIGH)&&(sensor3==LOW)&&(sensor4==HIGH))

{ digitalWrite(lmotorf,HIGH); digitalWrite(rmotorf,HIGH); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); } else if((sensor2==LOW)&&(sensor3==HIGH)&&(sensor4==LOW))

{ digitalWrite(lmotorf,HIGH); digitalWrite(rmotorf,HIGH); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); } else if((sensor1==HIGH)&&(sensor5==LOW)&&(sensor2==LOW)&&(sensor3==HIGH)&&(sensor4==LOW))//1 LEFT

{ digitalWrite(lmotorf,HIGH); digitalWrite(rmotorf,LOW); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); }

else if((sensor1==LOW)&&(sensor5==HIGH)&&(sensor2==LOW)&&(sensor3==HIGH)&&(sensor4==HIGH))//1 LEFT

{ digitalWrite(lmotorf,HIGH); digitalWrite(rmotorf,LOW); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); } else if((sensor1==HIGH)&&(sensor5==LOW)&&(sensor2==LOW)&&(sensor3==LOW)&&(sensor4==LOW))//1 LEFT

{ digitalWrite(lmotorf,HIGH); digitalWrite(rmotorf,LOW); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); }

else if((sensor1==LOW)&&(sensor5==HIGH)&&(sensor2==HIGH)&&(sensor3==HIGH)&&(sensor4==HIGH))//NULL

{ digitalWrite(lmotorf,HIGH); digitalWrite(rmotorf,LOW); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); } else if((sensor2==LOW)&&(sensor3==LOW)&&(sensor4==HIGH))//1 LEFT

{ digitalWrite(lmotorf,HIGH); digitalWrite(rmotorf,LOW); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); } else if((sensor2==LOW)&&(sensor3==HIGH)&&(sensor4==HIGH))//1 LEFT

{ digitalWrite(lmotorf,HIGH); digitalWrite(rmotorf,LOW); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); }

else if((sensor2==HIGH)&&(sensor3==LOW)&&(sensor4==LOW))//FOR RIGHT

{ digitalWrite(lmotorf,LOW); digitalWrite(rmotorf,HIGH); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); }

else if((sensor2==HIGH)&&(sensor3==HIGH)&&(sensor4==LOW))//FOR RIGHT

{ digitalWrite(lmotorf,LOW); digitalWrite(rmotorf,HIGH); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); } else if((sensor1==HIGH)&&(sensor5==LOW)&&(sensor2==HIGH)&&(sensor3==HIGH)&&(sensor4==HIGH))//1 LEFT { digitalWrite(lmotorf,LOW); digitalWrite(rmotorf,HIGH); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); } else if((sensor1==HIGH)&&(sensor5==LOW)&&(sensor2==HIGH)&&(sensor3==HIGH)&&(sensor4==LOW))//1 LEFT { digitalWrite(lmotorf,LOW); digitalWrite(rmotorf,HIGH); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); }

else if((sensor1==LOW)&&(sensor5==HIGH)&&(sensor2==LOW)&&(sensor3==HIGH)&&(sensor4==LOW)) { digitalWrite(lmotorf,LOW); digitalWrite(rmotorf,HIGH); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); } else if((sensor1==HIGH)&&(sensor5==LOW)&&(sensor2==HIGH)&&(sensor3==HIGH)&&(sensor4==HIGH)) { digitalWrite(lmotorf,LOW); digitalWrite(rmotorf,HIGH); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); }

else if((sensor2==HIGH)&&(sensor3==HIGH)&&(sensor4==HIGH))//FOR RIGHT { digitalWrite(lmotorf,HIGH); digitalWrite(rmotorf,HIGH); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); } else { digitalWrite(lmotorf,LOW); digitalWrite(rmotorf,LOW); digitalWrite(lmotorb,LOW); digitalWrite(rmotorb,LOW); }

}

I hope this was helpful !

All the best and Have fun :)