Search code examples
androidcinterruptesp8266arduino-esp8266

AttachInterrupt on ESP8266 with Arduino Firmware


I'm trying to figure out how the AttachedInterrupt works on the NodeMCU. Everything I found tells me that this code is OK?!

void setup() {
  Serial.begin(9600);
  pinMode(D4, INPUT);
  attachInterrupt(D4, doSth(), CHANGE);
}

void loop() {
  Serial.println(digitalRead(D4));
  delay(100);
}

void doSth() {
  Serial.println("Check!");
}

But I just get this error:

enter image description here

I still have no idea after hours of research!

Thanks a lot in advance :-)


Solution

  • Problem solved — Thanks again!

    I just used attachInterrupt(D4, doSth, CHANGE);

    instead of attachInterrupt(D4, doSth(), CHANGE);