#define ENCODER_CLK 35
#define ENCODER_DT 32
#define ENCODER_SW 33
#define jump 4
int val_jump;
int counter = 0;
void setup() {
Serial.begin(115200);
pinMode(ENCODER_CLK, INPUT);
pinMode(ENCODER_DT, INPUT);
pinMode(ENCODER_SW, INPUT_PULLUP);
pinMode(jump, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(ENCODER_CLK), readEncoder, FALLING);
}
void readEncoder() {
int dtValue = digitalRead(ENCODER_DT);
if (dtValue == HIGH) {
counter++; // Clockwise
}
if (dtValue == LOW) {
counter--; // Counterclockwise
}
}
int getCounter() {
int result;
noInterrupts();
result = counter;
interrupts();
return result;
}
void loop() {
Serial.println(counter);
if (digitalRead(ENCODER_SW) == LOW) {
}
}