OneButton library doesn't work with nodeMCU - HELP

Hi,

I feel like I've tried everything but nothing will work.
It seems that the OneButton library just wont work with the NodeMCU board, Please help, I don't know what to do or what to change in the library.

This is the library: GitHub - mathertel/OneButton: An Arduino library for using a single button for multiple purpose input.

Basically, nothing happens

This is my code:

#include "Arduino.h"
#include "WiFiClient.h"
#include "ESP8266WiFi.h"
#include <Stepper28byj48.h>
#include "ESP8266WebServer.h"
#include <OneButton.h>

//all this stuff is for my project

//Stepper config
Stepper28byj48 stepper(D5, D6, D7, D8);

//button
OneButton button(D1, true);

//Let's assign some variables for the pins
const int led = D0;
String doorstate = "";

void click() {
  Serial.println("test - Pressed");
}

void setup() {
  Serial.println("Initializing...");
  Serial.begin(115200);

  button.attachClick(click);
}

void loop() {

button.tick();

if(button.isLongPressed()) {
  Serial.println("Pressed");
}

delay(10); //Said so on the internet
}

I did try downloading the file and I am also encountering the same issue (none of the sketches seem to compile). It seems to me like maybe to library is too old (considering nothing has been updated for 2-3 years). However, I am not an expert at Arduino, so there is a chance that I am wrong. Is it possible to post the error you are getting?

Basically, nothing happens

You have not defined for anything to happen. You need to define the functions that you want called when the switch changes states, in a variety of ways.

PaulS:
You have not defined for anything to happen. You need to define the functions that you want called when the switch changes states, in a variety of ways.

But I'm pretty sure that I have.
This method (button.tick() ) checks the button and if it's been clicked, the library will run the code declared in the attachClick function.

Also what about this code in the loop function?

if(button.isLongPressed()) {
  Serial.println("Pressed");
}

This method (button.tick() ) checks the button and if it's been clicked, the library will run the code declared in the attachClick function.

I missed that. Sorry.

Put some Serial.print() statement in the library, and see what it is doing.

One thing that the library is doing wrong is diddling with the hardware in the constructor. When the constructor runs, before init() is called, the hardware is not ready to be diddled with.

That may be a problem on your hardware.

PaulS:
I missed that. Sorry.

Put some Serial.print() statement in the library, and see what it is doing.

One thing that the library is doing wrong is diddling with the hardware in the constructor. When the constructor runs, before init() is called, the hardware is not ready to be diddled with.

That may be a problem on your hardware.

No worries (:

When is init() called? In the backround at the beginning of setup()?

It is called at the beginning of main() before setup().

I found the problem!
It was a typo in the library code. Don't know if i caused it or if it was there from the beginning but it lacked:
_pin = pin;

Apparently the library used both _pin and pin for the pin.

Anywas, thank you guys for your help! (: