symbol PB = pin4
symbol Cam1 = 0
symbol state = b0
main:
readadc 4, b1
debug b1
if b1 => 195 then goto ledon
if b1 =< 194 then goto ledoff
; ---------------------
ledon:
state = 0 ; first of 3 possible states, but only 2 are explicitly used
do ; begin main ledon loop
do
loop until PB = 0 ; twiddle until pin4 goes low
do
pause 5
loop until PB=1 ; twiddle, sampling every 5, until pin4 goes high
pause 5 ; wait for something
inc state ; bump state
if state > 2 then ; if state is too high,
state = 0 ; wrap
end if
on state gosub ledon, ledoff ; states 0 and 1 turn led on and off
; state 2 apparently falls through and
; jumps to ledon. So states 0 and 2
; jump to ledon, state 1 to ledoff
; also, you're calling without a return, which should
; promptly crash the program,
; presuming this language uses a stack to store the
; return addresses from calls, which I suppose it must.
loop ; end main ledon loop (is an unconditional loop legal?)
end ; die unconditionally ; ***NEVER EXECUTES***
high cam1 ; turn on (?a camera?) ; ***NEVER EXECUTES***
goto main ; ***NEVER EXECUTES***
; ---------------------
ledoff:
low cam1 ; turn off whatever it is
goto main ; jump to top