AttachInterrupt on NodeMCU

pxlstuermer
Posts: 1
Joined: Wed Jan 18, 2017 10:47 pm

AttachInterrupt on NodeMCU

Postby pxlstuermer » Wed Jan 18, 2017 10:50 pm

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


Code: Select all

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:


Image


I still have no idea after hours of research!
Thanks a lot in advance :-)

Tercero
Posts: 1
Joined: Fri Mar 24, 2017 5:48 pm

Re: AttachInterrupt on NodeMCU

Postby Tercero » Fri Mar 24, 2017 5:53 pm

attachInterrupt expect a pointer to the function, not its returned value. If you call doSth(), you get the returned value, in your case, it's a void.
Try to remove the parenthesis after doSth:

Code: Select all

attachInterrupt(D4, doSth, CHANGE);

Who is online

Users browsing this forum: No registered users and 2 guests