This code enables the connection of a rotary encoder. CODE: encoder.bas D0=16:D1=5:D2=4:D3=0:D4=2:D5=14:D6=12:D7=13:D8=15:D9=3:D10=1 count = 0 SW = 5 DT = 4 CLK = 14 pin.mode SW, input, pullup pin.mode DT, input, pullup pin.mode CLK, input, pullup interrupt CLK, encoder interrupt SW, switch wait encoder: if pin(CLK) = pin(DT) then count = count - 1 else count = count + 1 print "count", count return switch: print "switch", pin(SW) return |
How To ... >