arduino
arduino copied to clipboard
[Rotary] A Version 2.0 without macros.
Hi Ben, Thank you for this excellent rotary encoder lib. I tried many many options and your approach is the best by far.
I did some changes to use it as a header only lib and without relying on macros, so it can be used like this:
#include <RotaryEncoder.h>
Rotary<HalfStepEncoder, INPUT_PULLUP> e(9,8);
void setup() {
e.begin();
Serial.begin(9600);
}
void loop() {
int dir = e.process();
if (dir == DIR_CW)
{
Serial.println(">>");
}
else if (dir == DIR_CCW)
{
Serial.println("<<");
}
}
The complete and compact code is here: https://gist.github.com/mnesarco/9f138cef1308904ba3050324feb0d9e6
It would be great to know your opinion.
Cheers, Frank.