Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Iisfaq
#21399 Hi

I notice there is a user button connected to GPIO 16 on the nodeMCU hardware (physical button bottom left)

Image

I have set my code as follows

Code: Select allvoid setup()
{
  Serial.begin(115200);
  pinMode(16, INPUT);
}


void loop() {

  Serial.print("Pin16=");
  Serial.println(digitalRead(16));

  delay(1000);
}


Now when the script runs it shows Pin16=1

If I click the button it then shows Pin16=0 and a little blue lamp shines brightly.

When I let the button go the Pin16 remains at 0 and the little blue light shines dimly.

How am I supposed to use this button?

If I change the pinMode to

Code: Select allpinMode(16, INPUT_PULLDOWN);


It then just displays 0 all the time.
User avatar
By tytower
#21445 When you program it you hold the flash button down and power on then let it go . Is that how it works ? I don't know as I have not had one or studied it . Only guessing so you have some answer at least

If that is the case then I would imagine the other button works the same but holds the GPIO0 pin high and power on then let it go .

You would have to look at the circuit diagram for the board to see what pins are involved .
User avatar
By Iisfaq
#21483
martinayotte wrote:Did you tried setting it with pinMode(16, INPUT_PULLUP); ? ;)


The documentation on https://github.com/esp8266/Arduino under Basic Wiring seems to specifically mention the following

GPIO0-GPIO15 can be INPUT, OUTPUT, INPUT_PULLUP, and INPUT_PULLDOWN. GPIO16 can be INPUT, OUTPUT or INPUT_PULLDOWN


Hence the reason I have not tried INPUT_PULLUP