int CLK=2;
int DT =3;
void setup() {
Serial.begin(115200);
pinMode(CLK, INPUT);
pinMode(DT, INPUT);
}
int last = HIGH;
void loop() {
int clkValue = digitalRead(CLK);
if (clkValue != last) {
// There was a change on the CLK pin
last = clkValue;
int dtValue = digitalRead(DT);
if (clkValue == LOW && dtValue == HIGH) {
Serial.println("Rotated clockwise ⏩");
}
if (clkValue == LOW && dtValue == LOW) {
Serial.println("Rotated counterclockwise ⏪");
}
}
}