// KY-040 Rotary Encoder  docs.wokwi.com/parts/wokwi-ky-040   2021, Uri Shaked
#define ENCODER_CLK 2
#define ENCODER_DT  3   //direction ⏩,⏪  dtValue - const
// SW off, button
//newClk = digitalRead(...    => "единичные" повороты ручки
// ? 24 «тика» – шага

int counter;

void setup() { Serial.begin(9600);
  pinMode(ENCODER_CLK, INPUT);
  pinMode(ENCODER_DT,  INPUT);
}


int lastClk = HIGH;


void loop() {
  int newClk = digitalRead(ENCODER_CLK); 
 Serial.println(newClk);     delay(100);
   
  
  if (newClk != lastClk) { // There was a change on the CLK pin
    lastClk = newClk;
    int dtValue = digitalRead(ENCODER_DT);
     if (newClk == LOW && dtValue == HIGH) Serial.println("Rotated clockwise ⏩");
   //if (newClk == LOW && dtValue == LOW) Serial.println("Rotated counterclockwise ⏪");
  }
}