-->
Page 1 of 3

NodeMCU - running arduino - User Button

PostPosted: Tue Jun 23, 2015 12:51 pm
by Iisfaq
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.

Re: NodeMCU - running arduino - User Button

PostPosted: Tue Jun 23, 2015 8:18 pm
by tytower
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 .

Re: NodeMCU - running arduino - User Button

PostPosted: Tue Jun 23, 2015 9:03 pm
by martinayotte
Did you tried setting it with pinMode(16, INPUT_PULLUP); ? ;)

Re: NodeMCU - running arduino - User Button

PostPosted: Wed Jun 24, 2015 1:48 am
by Iisfaq
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