I am using ESP32. I am working with inbuilt led on GPIO 2. I want to read the level of pin.
let led = 2;
GPIO.set_mode(led, GPIO.MODE_OUTPUT);
GPIO.write(led, 0);
Timer.set(1000, true, function(){
print(GPIO.read(led)==0);
if (GPIO.read(led)==0){
GPIO.write(led, 0);
}
else{
GPIO.write(led, 1);
}}, null);
the print statement only printing ‘0’ on console although led light is on. what’s wrong with code and why GPIO.read() not working properly?