Chat freely about the open source Javascript projects for ESP8266

User avatar
By hygy
#32828 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
User avatar
By jankop
#32843 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.
You do not have the required permissions to view the files attached to this post.
User avatar
By hygy
#32844 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" });
User avatar
By jankop
#32845 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" });