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

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


2 Replies to “Keyes IR obstacle avoidance sensor

  1. The EN (enable) Pin will not work unless you remove the EN jumper. To work properly, it is important to use the EN function because the HS0038BD IR sensor module is expecting pulses of 38Khz IR light. If will interpret a steady IR signal of any frequency, including 38Khz, as noise, and attenuate it. See the data sheet.

    1. Hi Bud !
      Thank you for the information. I’ll update the post to reflect your comment!

      Thank you again and best regards

Leave a Reply to feiticeir0 Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.