#define CLK 2
#define ENCODER 3
int counter=0;
void setup() {
Serial.begin(115200);
pinMode(CLK, INPUT);
pinMode(ENCODER, INPUT);
}
int lastClk = HIGH;
void loop() {
int newClk = digitalRead(CLK);
if (newClk != lastClk) {
lastClk = newClk;
int dtValue = digitalRead(ENCODER);
if (newClk == LOW && dtValue == HIGH) {
counter++ ; if(counter > 10){counter = 10;}
Serial.println(counter);
}
if (newClk == LOW && dtValue == LOW) {
counter--; if(counter < 0){counter = 0;}
Serial.println(counter);
}
}
}