brianlow / Rotary

Rotary encoder library for Arduino
233 stars 73 forks source link

Changes detected only after two mechanical steps #19

Closed AlFreddyTo closed 3 years ago

AlFreddyTo commented 3 years ago

Hi all,

I am quite new to Arduino, just managed to gather enough info for writing a sketch for a dishwasher and it is working. I used this library for the rotary encoder based menu. But changes are only detected after two mechanical steps, I cannot find a way to detect every single click. I tried with #define HALF_STEP but made no change. The encoder is a KY-040:

https://www.rcscomponents.kiev.ua/datasheets/ky-040-datasheet.pdf

Any help appreciated, thanks !

voneiden commented 3 years ago

I tried with #define HALF_STEP but made no change

By uncommenting the the statement in Rotary.h or some other way? It seems unlikely that there is no observable difference if HALF_STEP is truly enabled.

AlFreddyTo commented 3 years ago

By uncommenting the the statement in Rotary.h

Thanks, that easy step made the trick, sorry for the silly question but I missed that instruction in the library file. All good now.

voneiden commented 3 years ago

No problem, you're not the first one. The define needs to be before the ifdef check in Rotary.h, so it's an easy trap to fall into. So another way, if you want to keep the define in your sketch rather than modifying the library, is to have the define before the include of Rotary.h. I didn't check though, but I think that should work.