vfo_oled/lib/Rotary/examples/Polling/Polling.ino

25 lines
444 B
Arduino
Raw Permalink Normal View History

2024-01-26 10:26:49 -06:00
/*
Rotary Encoder - Polling Example
The circuit:
* encoder pin A to Arduino pin 2
* encoder pin B to Arduino pin 3
* encoder ground pin to ground (GND)
*/
#include <Rotary.h>
Rotary r = Rotary(2, 3);
void setup() {
Serial.begin(9600);
r.begin(true);
}
void loop() {
unsigned char result = r.process();
if (result) {
Serial.println(result == DIR_CW ? "Right" : "Left");
}
}