COMPONENTS REQUIRED:-
Arduino Board X 1
IR Sensors X 1
LED X 1
Theory-
Arduino interfacing with IR Proximity sensor is very simple like interfacing of Switch with the Arduino, The obstacle sensor gives logic 0 as output when there is no obstacle in front of it, and when obstacle is placed in front of it, it will give logic high output i.e. +5V. We need to read these logic changes on the Arduino. Using digitalRead Command. In my design I have connected its output to Pin 2 of Arduino You can use any other IO line as per your requirement.
CODE-
const int ProxSensor=2;
void setup()
{
pinMode(13, OUTPUT);
pinMode(ProxSensor,INPUT);
}
void loop()
{
if (digitalRead(ProxSensor)==HIGH)
{
digitalWrite(13, HIGH);
}
else
digitalWrite(13, LOW);
delay(100);
}
*If you face any difficulties in making this project drop a message