- My goal is:I am using ESP32. I am working with inbuilt led on GPIO 2. I want to read the level of pin.
- My actions are:
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 result I see is: the print statement only printing ‘0’ on console although led light is on.
- My expectation & question is: what’s wrong with code and why GPIO.read() not working properly?