How to use IR Sensor


What is an Ir sensor?

 An infrared sensor is an electronic device that measures and detects infrared radiation in its surrounding environment. ... When an object comes close to the sensor, the infrared light from the LED reflects off of the object and is detected by the receiver.

How to Work an Ir sensor?

Active infrared sensors both emit and detect infrared radiation. Active IR sensors have two parts: a light-emitting diode (LED) and a receiver. When an object comes close to the sensor, the infrared light from the LED reflects off of the object and is detected by the receiver.



Ir Sensor Parts & Pinout






Ir sensor circuit diagram



How to use Ir sensor with Arduino UNO

REQUIRED MATERIALS,

       Arduino UNO---- https://m.banggood.com/beelink/muvGs8

         IR Sensor---- https://m.banggood.com/beelink/vzbbQZ

          Jumper wires---- https://m.banggood.com/beelink/muvGsx

         Breadboard---- https://m.banggood.com/beelink/ruzGst



 How to connect a sensor to Arduino UNO
you can use an indicator LED for pin 12




How to Program Ir sensor with Arduino UNO 

void setup() {
  // put your setup code here, to run once:
pinMode(2,INPUT);
pinMode(12,OUTPUT);//LED
}

void loop() {
  // put your main code here, to run repeatedly:
if(digitalRead(2)==LOW){
  digitalWrite(12,HIGH);
}
else{
  digitalWrite(12,LOW);
}
}

Ir sensor Video tutorial




--------------------------------------------------------------------------------


If you think this is important, subscribe to my youtube channel to know more like this.