String arah;
int initial;
int last;
int hitung = 0;
int CLK = 27;
int DT = 14;
int SW = 12;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(CLK, INPUT);
pinMode(DT, INPUT);
pinMode(SW, INPUT_PULLUP);
last = digitalRead(CLK);
}
void loop() {
// put your main code here, to run repeatedly:
initial = digitalRead(CLK);
if (digitalRead(DT) != initial){
hitung --;
arah = "counter clockwise";
}
else {
hitung ++;
arah = "clockwise";
}
delay(10); // this speeds up the simulation
Serial.println(arah);
initial = last;
}