' pin 38 Backlight
' pin 21 Encoder Button
' pin 1 Encoder A
' pin 2 Encoder B
BR ="
"
meter a,0,1
meter b,0,1
html BR
oa = 1
ob = 1
ro = ""
textbox a
textbox b
textbox p
textbox r
html "
X = "
textbox x
timer 20,tim
tim:
a = pinIn(1)
b = pinIn(2)
p = pinIn(21)
' R L
'11 11 idle
'10 01 1
'00 00 stop
'01 10 2
'11 11 idle
if oa=1 and ob=1 and a = 0 and b = 1 then r ="links1"
if oa=1 and ob=1 and a = 1 and b = 0 then r ="rechts1"
if oa=0 and ob=0 and a = 1 and b = 0 then r ="links2"
if oa=0 and ob=0 and a = 0 and b = 1 then r ="rechts2"
if a = 1 and b = 1 then r ="idle"
if a = 0 and b = 0 then r ="stop"
oa = a
ob = b
if r = "rechts1" and ro <> "rechts1" then x = x + 1
if r = "links1" and ro <> "links1" then x = x - 1
ro = r
pinOut 38,p
wait