Introduction: Basic Line Follower Description

About: i just love robotics.

The IR line tracking sensor consists of analog to digital and
comparator module and TCRT5000 IR Sensor Breakout Board. The IR light emitted by the LED strikes the surface and is reflected back to the IR photodiode. The photodiode then gives an output voltage proportional to the reflectance of the surface (high value for light surface and low for black/dark surface). This line follower robot are pretty straight forward. These robots have the capability to detect a black/dark line on a lighter surface depending on the contrast. They estimate whether the line underneath them is shifting towards their left/right as they move over them. Based on that estimation, they give respective signals to the motors to turn left/right so as to maintain a steady center with respect to the line. These robots usually use an array of IR (Infrared) sensors in order to calculate the reflectance of the surface beneath them. The basic criteria being that the black line will have a lesser reflectance value (black absorbs light) than the lighter surface around it. This low value of reflectance is the parameter used to detect the position of the line by the robot. The higher value of reflectance will be the surface around the line. So in this linear array of IR sensors, if the leftmost/rightmost IR sensor presents the low value for reflectance, then the black line is towards the left/right of the robot correspondingly. The controller then compensates for this by signaling the motor to go in the opposite direction of the line.

Step 1: Step 1:Material

1.ardunio uno

2.motor driver h bridge(l293d)

3.car chassis

4.wheels and motors of 150 rpm

5.some jumpers

6.battery

7.ir sensor

8.black tape

9.double sided tape

Step 2: Step 2: Hardware Installation

1. Assemble the 2WD Smart Car Chasis 2 Wheels

2. Connect the IR sensor to Ardunio pin

uno pin no 3---IR Sensor 1
uno pin no 4---IR Sensor 2

3. Then, connect the output pin 6,7,8,9 to motor driver

4. Connect Vin to 5V and GND to GND in Arduino UNO

5. Connect the both motor to motor driver


Step 3: Step 3: Insert Source Code

1. copy the code and paste it in Arduino software or IDE.
2. Make sure that you have choose the right board and the corresponding port. (In this tutorial, Arduino Uno is used) 3. Then, upload the test code into your Arduino Uno.

int m1 = 6;
int m2 = 7; int m3 = 8; int m4 = 9; int s1 = 3; int s2 = 4; int a,b;
void setup() {                
 pinMode(m1, OUTPUT);
 pinMode(m2, OUTPUT);
 pinMode(m3, OUTPUT);
 pinMode(m4, OUTPUT);
 pinMode(s1, INPUT);
 pinMode(s2, INPUT);
}
void loop() {
  a=digitalRead(s1);
  b=digitalRead(s2);
  if(a==HIGH && b==HIGH)
  {
    digitalWrite(m1, HIGH);
    digitalWrite(m2, LOW);
    digitalWrite(m3, HIGH);
    digitalWrite(m4, LOW); 
  }
  if(a==HIGH && b==LOW)
  {
    digitalWrite(m1, HIGH);
    digitalWrite(m2, LOW);
    digitalWrite(m3, LOW);
    digitalWrite(m4, LOW); 
  }
  if(a==LOW && b==HIGH)
  {
    digitalWrite(m1, LOW);
    digitalWrite(m2, LOW);
    digitalWrite(m3, HIGH);
    digitalWrite(m4, LOW); 
  }
  if(a==LOW && b==LOW)
  {
    digitalWrite(m1, LOW);
    digitalWrite(m2, HIGH);
    digitalWrite(m3, LOW);
    digitalWrite(m4, HIGH); 
  }
}