Keyes IR obstacle avoidance sensor

Keyes IR obstacle avoidance sensor


The Funduino Tracking Maze Robot also comes with 3 IR Obstacle Avoidance Sensors. I couldn’t find any information about it, but i found information about similar ones and give it a try.

The sensor works by sending infrared rays of certain frequency. When the infrared ray meets an obstacle(reflection surface), it is reflected and received by receiver. Then the corresponding indicator light is on. The sensor has a potentiometer knob you can adjust to change the detection distance. I’ve managed to work with 10,5 cm (roughly 4.1 inches).

Although the sensor has 4 PINs, only the first 3 are used. The last PIN, apparently does nothing (but correct me if i’m wrong).  I went trying to work with it using the PIN – EN – as an activation sensor PIN (putting it in HIGH) and deactivating the sensor (putting it on LOW), but the result was the same. The sensor always worked. When reading, the input is always 1.

Here are the connections of the sensor (from GND to EN)

GND Vcc Input signal EN – not used

And, for testing with the Arduino, the connection PINs:

Sensor Arduino
+ 5v
Out PIN 9
EN Not used


Here a small code to test the sensor

* IR obstacle avoidance sensor testing
* Free to share !
int count;
void setup() {

 Serial.begin (9600);
 pinMode (9, INPUT); //Sensor output
void loop() {
Serial.print ("Sensor: ");
 Serial.println (digitalRead(9)); //print the sensor output
 delay (500); //wait half a second

By default, the sensor returns 1. When detecting something, the sensor returns 0.