Help regarding gpio16 pin on esp8266MOD
Posted: Mon Jun 04, 2018 9:39 am
Hello everyone,
I am an absolute beginner in esp8266MOD so i need help regarding the gpio16 pin of the board. I have set the gpio16 as an input pin which receives input from a pushbutton connected to the ground. The D7 pin is used as an output to an external led. The goal is to turn on the led when the button is pressed and turn it off when the button is released. However when the button is pressed the led turns on but after the button is released nothing happens, the led glows on forever. I am not facing this issue with other I/O pins.
This is my first time asking a question ,please pardon any mistakes. Thanks in advance !
I am an absolute beginner in esp8266MOD so i need help regarding the gpio16 pin of the board. I have set the gpio16 as an input pin which receives input from a pushbutton connected to the ground. The D7 pin is used as an output to an external led. The goal is to turn on the led when the button is pressed and turn it off when the button is released. However when the button is pressed the led turns on but after the button is released nothing happens, the led glows on forever. I am not facing this issue with other I/O pins.
Code: Select all
void setup() {
// initialize the LED pin as an output:
pinMode(D7, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(D0, INPUT_PULLUP);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(D0);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(D7, LOW);
} else {
// turn LED off:
digitalWrite(D7, HIGH);
}
}
This is my first time asking a question ,please pardon any mistakes. Thanks in advance !