A: You may have set the sensitivity too high. The sensor is detecting the floor or table surface. Turn the potentiometer counter-clockwise until the detection stops.
else objectDetected = false; digitalWrite(ledPin, LOW); // Turn LED OFF // No output for "clear" to avoid spamming. Fc 51 Ir Sensor Datasheet
// Since output is Active LOW, "LOW" means object detected if (sensorState == LOW) digitalWrite(ledPin, HIGH); Serial.println("Obstacle detected!"); else digitalWrite(ledPin, LOW); Serial.println("Path clear"); A: You may have set the sensitivity too high
pinMode(2, INPUT); pinMode(13, OUTPUT); if (digitalRead(2) == LOW) digitalWrite(13, HIGH); else digitalWrite(13, LOW); if (digitalRead(2) == LOW) digitalWrite(13