-->
Page 1 of 2

nodemcu button

PostPosted: Mon Nov 02, 2015 9:35 am
by hygy
Hi,

I try to set up a button with nodemcu 0.9 there is a user button what is connected to GPIO16, but I cant make it work.

So i connected a wire between D0 and I can connect it to 3.3V or GND, but nothing works.

Can somebody please provide me an example code, and what nodemcu pin I need to use to connect my wire?

thanks
bye
HyGy

Re: nodemcu button

PostPosted: Mon Nov 02, 2015 11:20 am
by jankop
Hi,
GPIO16 is default as output for wake from a deep sleep . The attached picture is of NODEMCU kit 1.0.
So it should be properly connected. Active reset and wakeup from GPIO16 as option. GPIO16 as input is not optimal.

Re: nodemcu button

PostPosted: Mon Nov 02, 2015 11:28 am
by hygy
Can U please tell me a correct pin, and a sample code?

Like this:

Code: Select allvar button = new Pin(xxxxxx);

pinMode(button, 'input_pulldown');

setWatch(function() {
  console.log('aaaaaaa');
}, button, { repeat: true, debounce : 50, edge: "rising" });

Re: nodemcu button

PostPosted: Mon Nov 02, 2015 11:45 am
by jankop
Your example is OK. Try it for GPIO0 and HIGH to LOW change.

Code: Select allvar button = new Pin(0);

pinMode(button, 'input_pullup');

setWatch(function() {
  console.log('aaaaaaa');
}, button, { repeat: true, debounce : 50, edge: "falling" });