I would have to say your problem is using an "IF" statement inside the "FOR...NEXT" loop. Also you do realize the PAUSE 1 = 1mS and not 1s. I also noticed there is not main program loop, do you in fact what the program to stop once it has read the pulse width?
Code:
start:
counter = 0
loop:
counter = counter + 1
pulsin 4,1,pulsewidth
if pulsewidth >150 then
gosub switch
endif
if pulsewidth=0 then
gosub blink
endif
pulsin 4,1,pulsewidth
pause 1
if counter = (looptime - 1 ) then
gosub wakeup
endif
goto start
switch:
blah, blah, blah...
return
blink:
blah, blah, blah...
return
wakeup:
blah, blah, blah...
return
Bookmarks