pinA = 1 ' Encoder A pinB = 2 ' Encoder B tft.text.datum(4) tft.text.color(65535,0) tft.cls() tft.print("Encoder Test") rot = 0 r = 0 oc = 1 interrupt pinA,[change] interrupt pinB,[change] interrupt 21,[push] Wait [change] if io(laststat,pinA) = 1 then a = 1 else a = 0 if io(laststat,pinB) = 1 then b = 1 else b = 0 c = a + b rot = 0 if c = 1 and oc = 2 then if a = 1 and b = 0 then rot = 1 if a = 0 and b = 1 then rot = -1 gosub [dorotate] endif oc = c wait [dorotate] if rot > 0 then inc r if rot < 0 then dec r rot = 0 gosub draw return [push] if io(laststat,21) = 1 then rr = 0 else rr = -1 if rr then r = 0 gosub draw endif wait [draw] s = " " & str(r) & " " tft.text.draw(s,160,60,7) return