I have the ESP8266 12e, I have performed the following connection (shown below), but on D0 (GPIO16), when I do this, the second blue light turns on, what is this light, is this a bad thing?
Is there a way to set up the same circuit with (I think up to 16 times/terminals) but using only one resistor, (note, that I only need inputs, no outputs including LEDs)?
Is there anything that I should know about when setting up 16 buttons? Is this the max, or is it less (or more)?
1. This is the picture (Fig-1) of my NodeMCU (ESP8266-12E) with two onboard Blue LEDs which I have marked as Led1 and Led2.
Figure-1:
2. Led1 is connected internally with GPIO-4/D4, and it blinks during sketch uploading. The Led1 also responds to blink program of Step-4.
3. Led2 is connected internally with GPIO-16/D0. The Led2 also responds to blink program of Step-4. Caution: Do not connect any circuit with GPIO-16/D0 during sketch uploading as it prevents the sketch from uploading!
See the first part of this tutorial about how to use INPUT_PULLUP mode with a button. It shows how to wire diagonally across the button to guarantee you pick up switched legs.
1. Every GPIO-pin (when configured as an input line) can be optionally connected with an internal pull-up resistor (Fig-1). In that case, there is no need to use external pull-up or pull-down resistors.
Figure-1:
2. The following sketch checks that Button is closed and then turns on Led3.
#define Button 12 //GPIO-12
#define Led3 4
void setup()
{
Serial.begin(115200);
pinMode(Button, INPUT_PULLUP); //internal pull-up is connected
pinMode(Led3, OUTPUT);
digitalWrite(Led3, LOW); //Led3 is OFF
}
void loop()
{
if(digitalRead(Button) == LOW) //when Button is closed, logic level at Dpin-12 is LOW
{
digitalWrite(Led3, HIGH); //Led3 is ON
while(1); //wait for ever
}
}
3. Button is a mechanical switch, and it makes hundreds of make-and-break events before settling at the final closed position. This behavior is known as bouncing. If you want to detect the final state of the Button once bouncing has disappered, you may apply software debouncing by including the Debounce.h Library in the sketch. Here is the sketch that detects the closed condition of the debounced Button.
#include<Debounce.h>
Debounce Button(12); //Here, Button is an objcet attached with DPin-12
#define Led3 4
void setup()
{
Serial.begin(115200);
pinMode(12, INPUT_PULLUP); //internal pull-up is connected
pinMode(Led3, OUTPUT);
digitalWrite(Led3, LOW); //Led3 is OFF
}
void loop()
{
if(!Button.read() == LOW) //when Button is closed, logic level at Dpin-12 is LOW
{
digitalWrite(Led3, HIGH); //Led3 is ON
while(1); //wait for ever
}
}