1* Rotary Encoder Test Sketch
2* Outputs
"Turning" when rotated,
"PUSH" when pressed
5#include "RotaryEncoder.h"
12RotaryEncoder encoder(ENC_A, ENC_B, RotaryEncoder::LatchMode::TWO03);
17 pinMode(ENC_SW, INPUT_PULLUP);
18 Serial.println(
"Rotary Encoder Test Ready");
25 int newPos = encoder.getPosition();
26 if (newPos != lastPos) {
27 Serial.println(
"Turning");
32 static bool lastButtonState = HIGH;
34 if (
buttonState == LOW && lastButtonState == HIGH) {
35 Serial.println(
"PUSH");
void setup()
Arduino Setup Function.
void loop()
Arduino Loop Function.
bool buttonState[20]
Array to hold the current state of the 20 DDI buttons.