Write a program to sense Obstacle closer than 1 metre near an IR sensor interfaced with Arduino Uno.
Last Updated : 15 Jul 2025
Solution:
const int irpin = A2;
void setup(){
pinMode(irpin,INPUT);
Serial.begin(12700);
}
void loop(){
int reading=analogRead(irpin);
float volatage = reading*5/1023;
if(volatage<=3){
Serial.print("Object Detected")
}
else{
Serial.print("No Object Detected")
}
delay(3000);
delay(3000);
}
Report an error
Meanwhile you can watch this video
Watch Video