mathertel / RotaryEncoder

RotaryEncoder Arduino Library
Other
328 stars 107 forks source link

attachInterrupt missing digitalPinToInterrupt in example #27

Closed Meeresgott closed 3 years ago

Meeresgott commented 3 years ago

Tested your example with Interrupts (InterruptRotator.ino). There is no need the call encoder.tick() in the main loop if the interrupts would work.

Changed your attachInterrupt(PIN_IN1, checkPosition, CHANGE); attachInterrupt(PIN_IN2, checkPosition, CHANGE);

to

attachInterrupt(digitalPinToInterrupt(PIN_IN1), checkPosition, CHANGE); attachInterrupt(digitalPinToInterrupt(PIN_IN2), checkPosition, CHANGE); and deleted your tick in the main loop.

Tested on a Arduino Nano V3.

SamuelReinfelder commented 3 years ago

I have just encountered the same problem and found the same solution after an hour ;) .

Tested on Arduino Pro Micro

mathertel commented 3 years ago

Fixed with version 1.5.1. Thank you.