Hi everyone,
int LED = 13;
int isObstaclePin =2;
int isObstacle = HIGH; // HIGH MEANS NO OBSTACLE
void setup() {
pinMode(LED, OUTPUT);
pinMode(isObstaclePin, INPUT);
Serial.begin(9600);
}
void loop() {
isObstacle = digitalRead(isObstaclePin);
if (isObstacle == LOW)
{
Serial.println("OBSTACLE!!, OBSTACLE!!");
digitalWrite(LED, HIGH);
}
else
{
Serial.println("clear");
digitalWrite(LED, LOW);
}
delay(200);
}
As you can see:
this type of IR sensor come with three pins, I connected
VCC-> 5V
GND->GND
OUT_>D2
The IR sensor has indicators which are
Power LED->Illuminates when power is applied
Obstacle LED-> Illuminates when an obstacle is detected
There is suppose no error in code, nor the connection, as I followed the instruction in the link above. The IR sensor Obstacle LED on the module does detect when an object is approaching.
My problem is the serial monitor doesn't show Serial.println("OBSTACLE!!, OBSTACLE!!") even when the sensor detect object? I am using a Wemos D1 R1 board for my project by the way. Thank you!

