Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rotary] A Version 2.0 without macros. #14

Open
mnesarco opened this issue Jun 30, 2022 · 0 comments
Open

[Rotary] A Version 2.0 without macros. #14

mnesarco opened this issue Jun 30, 2022 · 0 comments

Comments

@mnesarco
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant