Arduino library for robust reading of rotary encoders.
Add these lib dependency line to your platformio.ini
lib_deps =
https://github.com/Jorgen-VikingGod/RobustRotaryEncoder.git
- Navigate to the Releases page.
- Download the latest release.
- Extract the zip file
- In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library
-
Reading rotary encoder increment value or directon (CW / CCW).
- begin()
- read()
- incrementValue()
- isChanged()
- isCW()
- isCCW()
There are some examples implemented in this library. One of the examples is below. You can find other examples here
#include <RobustRotaryEncoder.h>
#define ENCODER_A_PIN 6
#define ENCODER_B_PIN 7
RobustRotaryEncoder encoder;
void setup() {
// configure encoder
encoder.begin(ENCODER_A_PIN, ENCODER_B_PIN);
}
void loop() {
if (encoder.read()) {
// rotary encoder down
if (encoder.isCCW()) {
Serial.println("CCW");
}
// rotary encoder up
if (encoder.isCW()) {
Serial.println("CW");
}
}
}
This library is written by Juergen Skrotzky. Main code of the robust reading is based on code of John Main (best-microcontroller-projects.com).
RobustRotaryEncoder is free software: you can redistribute it and/or modify it under the terms of the MIT license.