🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X
Questions
























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
Latest Updates