The IR Obsctacle avoidance sensor is basically a sensor circuit. It contain a transmitter circuit that sending infrared light and a receiver circuit that receiving infrared light. In order for the receiver to receive infrared light, the IR light must return by hitting an obstacle.
How to work The IR Obsctacle avoidance sensor
When the 5V operating voltage is applied to VCC and GND pins, the transmitter emits IR light. If the IR light that hits an obstacle returns to the receiver, the IR obstacle avoidance sensor gives HIGH signal from the S pin. If there is no obstacle and therefore the light does not return to the receiver, the LOW signal is received from S pin.
If you want, you can change the distance detection sensitivity with the help of the potentiometer on this sensor circuit. The effective detection distance of the IR obstacle avoidance sensor is between 2cm and 40 cm.
IR Obsctacle avoidance sensor pinout
IR Obsctacle avoidance sensor specifications
- Operating voltage: 5V DC
- Current: ≥ 20mA
- Working temperature: -10 ℃ – +50 ℃
- Detection range :1cm – 40cm
- IO Interface: 4-wire interfaces (- / + / S )
- Output signal: TTL level
- Effective angle: 35 °
KY-032 Infrared Obstacle Sensor PinOut
KY-032 Keyes IR sensor has some differencies. KY -032 has 4 pin. One of them is EN (Enabled) pin. You can active or deactive the detection via EN pin. So that you can controll more effectively your projects.
IR Obsctacle avoidance sensor sample Arduino Project
The following Arduino circuit is a typical IR object detection circuit. In this circuit if IR sensor detects any object, it gives HIGH signal to Arduino 6th pin. Arduino send HIGH voltage to buzzer and led.
Sample Arduino Code:
#define led 4 // led at pin 4 #define buzzer 5 // buzzer at pin 5 #define sensor 6 // ir sensor at pin 6 int sound=250; // set buzzer sound void setup() { Serial.begin(9600); pinMode(sensor,INPUT); pinMode(led,OUTPUT); pinMode(buzzer,OUTPUT); } void loop() { int detect=digitalRead(sensor); // read status of sensor if(detect==HIGH){ digitalWrite(led,HIGH); tone(buzzer,sound); // buzzer sounds } else{ digitalWrite(led,LOW); noTone(buzzer); } delay(300); }