Description
- Digital reflection sensor with on-board comparator
- Useful for line following, anti-collision or edge detection
- 1.5 cm range
- Variable resistor for threshold tuning of reflective/non-reflective surfaces
- Built in LED indicator
- VCC input voltage 5V
- Easy to use and set up
This IR sensor can detect the difference between a reflective and a non-reflective (white/black) surface and output a TTL signal. On a reflective/white surface the output will be low. You can use it for line following, collision risk detecting or edge detection projects. With the on-board trim pot and LED indicator it’s easy to adjust the threshold sensitivity between reflective and non-reflective surfaces to suit any environment.
The sensor has 3 pins: a ground G pin, a V+ 5 volt power supply pin and an S signal pin.
Supply voltage | +3.3 to +5 VDC 20 mA |
Detection distance | 1.5 cm (on a white surface) |
Output | TTL, black or no reflection = logic HIGH, white or reflection = logic LOW |
Operating temperature | 0 to 50 ℃ |
Size | 42 * 10.5 mm |








Has only one signal pin. Use the male to female jumper cables to connect the module directly to the Arduino-compatible board.
To supply voltage to the board, connect the V+ pin to the 5v power pin and the G pin to the GND pin of your Arduino-compatible board. For our example, connect S to A2.
12345678910111213141516171819202122232425262728293031323334/*
By Dr. Mangus for Mango Labs
IR Sensor
V+ to 5V
G to GND
S to D2
*/
#define Digital 2 //Digital Input for IR Line Sensor Module
#define LED 13 //Build in LED at D13 pin
void
setup() {
//setup the input and output pins
pinMode(LED, OUTPUT);
pinMode(Digital, INPUT);
digitalWrite(LED, LOW);
//ensure LED is off
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void
loop() {
if
(digitalRead(Digital) == 1)
// if digital input is high
{
Serial.print(
"Non-Reflective"
);
digitalWrite(LED,LOW);
}
else
{
Serial.print(
"Reflective"
);
digitalWrite(LED,HIGH);
}
delay(300);
}
- In this example we are connecting:
Arduino IRL Sensor
D2 —– S
GND —– G
5V —– V+ - Download and install the Arduino environment from here or use the web editor.
- Download the sketch here and open or open the Arduino environment and copy the code into a blank sketch.
- Connect your board to your computer with the included USB cable.
- Select your board in Tools / Board / Arduino Uno.
- Select your port in Tools / Port / COM# (Arduino Uno). This may be slightly different depending on your operating system.
- Upload by pressing the arrow in the circle to the upper left.
- To open the serial monitor, press the magnifying glass icon on the upper right.
- Set the baud rate to 9600 on the lower right.
- A text will indicate whether you are on a reflective surface. The LED on pin 13 (labeled L) will turn on when you are on a reflective surface and off when you are not.That’s it!