-->
Page 1 of 3

attachInterrupt - Question

PostPosted: Sat Aug 22, 2015 2:46 pm
by brutzler
Just trying to use a rotary encoder on my NodeMCU.

But I am struggling with the interupts.
With an UNO there I could use only Interrupt 0/1 on Pin 2/3
Calling like this:
Code: Select all  attachInterrupt(0, doEncoderA, CHANGE);

In the Reference of ESP/Arduino I have seen this:
Pin interrupts are supported through attachInterrupt, detachInterrupt functions. Interrupts may be attached to any GPIO pin, except GPIO16. Standard Arduino interrupt types are supported: CHANGE, RISING, FALLING.


But I am missing the relation between interrupt and pin-number :?
What is the right interrupt, if I want to use GPIO4?

Re: attachInterrupt - Question

PostPosted: Sat Aug 22, 2015 3:36 pm
by martinayotte
It suppose to be direct relation, GPIO4 is pin4, so your code should have attachInterrupt(4, doEncoderA, CHANGE);

Re: attachInterrupt - Question

PostPosted: Sat Aug 22, 2015 8:25 pm
by brutzler
Oh you are right. Easier, than I thought :oops:
THX

Re: attachInterrupt - Question

PostPosted: Sat Aug 22, 2015 8:52 pm
by martinayotte
:P