How to use the Line Tracking Sensor with Arduino

How to use the Line Tracking Sensor with Arduino

Line Tracking Sensor Arduino

INTRODUCTION

This sensor can be used for line tracking purposes. It differentiates white and black colors and it outputs via a digital signal. Utilizing it enables your mobile robot to have intelligent line following functions, or anti-collision, or anti-edge falling. Good performance can be found if the object has a reflective surface.

APPLICATIONS

Its applications include line following robots, delivery or warehouse robots and also food serving robots in a restaurant.

WIRING DIAGRAM

VCC – 5V

GND - GND

Out – Digital Pin 8

You will need a sheet of white paper and a black sharpie to test the sensor. Go ahead an draw a line on the whitepaper.

CODE

const int tracingPin = 8;

const int ledPin = 13;

void setup()
{
pinMode(tracingPin, INPUT);
pinMode(ledPin, OUTPUT);
}

void loop()
{
int val = digitalRead(tracingPin);
if(val == HIGH)
{ 
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}

END RESULT

LED pin on the Arduino board will light up when the sensor is detecting black color on a white background.

ADDITIONAL RESOURCES

http://arduinolearning.com/code/ir-line-tracking-sensor-example.php