Esp8266 2-pin button not working correctly
Posted: Sun Feb 11, 2024 10:42 am
Hi guys i have one of those 2 pin buttons and im trying to connect it to my nodemcu 8266, using this code:
when i press the button once it goes from HIGH to LOW and stays on LOW forever unless i restart or replugg the 8266, any ideas?
one pin is connected to ground and the other to GPIO 16 on the esp8266
Code: Select all
//in setup:
pinMode(16, INPUT_PULLUP);
// in update:
int but1 = digitalRead(16);
if(but1 == HIGH){ }else{
Serial.print("BUTTON Low");
}
one pin is connected to ground and the other to GPIO 16 on the esp8266