aUCBLogo Demos and Tests / steppermotor
be steppermotor
adr=888
state=0
steps=10*48
speed=5000
print [If a stepper motor is connected be bit 0..3 of the parallel port]
print [then + F2 F3 F4 \ F5 F6 F7 - are the driving keys]
print [ESC stops]
running=true
while [running]
[ ch=readChar
if ch==char 27 [running=false]
if ch=="+ [drive steps]
if ch=="- [drive -steps]
if ch==char 255
[ ch=readCharExt
case ch
[ [WXK_F1 drive -steps]
[WXK_F2 drive lshift -steps -2]
[WXK_F3 drive lshift -steps -4]
[WXK_F4 drive lshift -steps -6]
[WXK_F5 drive lshift steps -6]
[WXK_F6 drive lshift steps -4]
[WXK_F7 drive lshift steps -2]
[WXK_F8 drive steps]
]
]
]
PortOut adr 255
be drive steps
ifelse steps < 0
[ drivebackward -steps
][ driveforward steps
]
end
be driveforward steps
if steps==0 [stop]
state=state+1
bits=BitNot UInt8 lshift 1 BitAnd state 3
PortOut adr bits
waituS speed
driveforward steps-1
end
be drivebackward steps
if steps==0 [stop]
state=state-1
bits=abs BitNot UInt8 lshift 1 BitAnd state 3
PortOut adr bits
waituS speed
drivebackward steps-1
end
end