Description
When infrared light fall on a white surface it is almost full reflected and in case of black surface light is completely absorbed. The sensor use an IR Transmitter and an IR receiver also called photo diodes. They are used for sending and receiving light.
When infrared rays falls on white surface, it’s reflected back and catched by photodiodes which generates some voltage changes. When IR light falls on a black surface, light is absorb by the black surface and no rays are reflected back, thus photo diode does not receive any light or rays.
Based on the above principle you can use the line follower sensor to sense white surface then arduino gets 1 as input and when senses black line arduino gets 0 as input.
Features:
Power supply: +5V
Operating current: <10mA
Operating temperature range: 0°C ~ + 50°C
Output interface: 3-wire interface (1 – signal, 2 – power, 3 – power supply negative)
Output Level: TTL level (black line of low effective, high efficient white line)
Getting started with the IR Line Tracking Sensor
In this experiment, we will use an IR track sensor module and the on-board LED to build a simple circuit to make a tracking line. Since the LED has been attached to pin 13, connect the pin OUT to digital pin 2 of the Uno board. When the tracking sensor detects reflection signals (white), the LED will be on. Otherwise, it will be off (black line).
Hardware required
- Arduino uno
- IR Line Tracking Sensor
- Jumper wires
Connecting the Hardware
Code Program
After above operations are completed, connect the Arduino board to your computer using the USB cable. The green power LED (labelled PWR) should go on.Open the Arduino IDE and choose corresponding board type and port type for you project. Then load up the following sketch onto your Arduino.
const int trackingPin = 2; //the tracking module attach to pin 2
const int ledPin = 13; //pin13 built-in led
void setup()
{
pinMode(trackingPin, INPUT); // set trackingPin as INPUT
pinMode(ledPin, OUTPUT); //set ledPin as OUTPUT
}
void loop()
{
boolean val = digitalRead(trackingPin); // read the value of tracking module
if(val == HIGH) //if it is HiGH
{
digitalWrite(ledPin, HIGH); //turn off the led
}
else
{
digitalWrite(ledPin, LOW); //turn on the led
}
}
RUNNING RESULT
A few seconds after the upload finishes, set it down on a piece of paper with a dark line (at least ½” wide). You may use a Sharpie Marker, electrical tape, or dark paint. When the module gets on a black line, it output LOW and the corresponding LED stays off; when it meets a white area, it outputs HIGH and the LED lights up.
Experiment 2 This code is used to acquire the signals of the sensor via the digital pin 2 and to output the signals into the computer via serial port. To observe the consequence, we can use serial monitor.
Copy the following codes and paste them in Arduino.
void setup()
{
Serial.begin(9600); //Set serial baud rate to 9600 bps
}
void loop()
{
Serial.println(digitalRead(2)); //Print the value to serial port
delay(1000);
}
RUNNING RESULT
Align the infrared detector with the black line, keep the height of the detector around 1cm, then the indicator light is off, and the output terminal outputs low level(0). If the detector is aligned with the white line with a height about 1cm, the indicator light is on and the output terminal outputs high level(1).