Objective:
To detect the objects using IR sensor.
Components Required
- Arduino Uno
- Infra Red Sensor
Connection Diagram
Program
int sensorPin = 3;
int sensorValue = 0;
void setup()
{
pinMode(sensorPin, INPUT);
Serial.begin(9600);
}
void loop()
{
sensorValue = digitalRead(sensorPin);
if(sensorValue==HIGH)
{
Serial.println(“Object Detected”);
}
else
{
Serial.println(“Object not Detected”);
}
}
Working
The output of the IR sensor is accessed by the Arduino Uno and displayed. Whenever the IR sensor detects the objects it produces HIGH voltage and If there is no objects detected it produces LOW voltage.
Output
The output value is : 1 (when object present)
The output value is : 0 (when object not present)