I was wondering if anyone could spot in the below code any reason why my b0 variable keep resetting? Basically, I have a switch on the board that each time its pressed it increases the b0 vaiable by 1. This then operates the length of the pause time between each color change.
However, If I say set the pause at 4, with 4 presses of the button, it for some reason just resets itself back to 0
However, If I say set the pause at 4, with 4 presses of the button, it for some reason just resets itself back to 0
Code:
#picaxe 08m2
#no_data
setfreq m16
symbol Red = 0
symbol Green = 1
symbol Blue = 2
symbol speed = w0
symbol on_time = w2
symbol off_time = w3
setint %00001000, %00001000
main:
readadc C.4,b3 ‘read the value
if b3<2 then chase ‘range 0-1
if b3>10 then lightsoff
goto main
lightsoff:
Low Green
Low Red
Low Blue
goto main
chase:
speed = b0 * 10000
RedOn:
for on_time = 0 to 5000 step 10
pulsout Red,on_time
off_time = 5000 - on_time
pauseus off_time
next on_time
high Red
pause speed
pause speed
pause speed
pause speed
pause speed
pause speed
BlueOff:
for on_time = 0 to 5000 step 10
pulsout Blue,on_time
off_time = 5000 - on_time
pauseus off_time
next on_time
low Blue
pause speed
pause speed
pause speed
pause speed
pause speed
pause speed
GreenOn:
for on_time = 0 to 5000 step 10
pulsout Green,on_time
off_time = 5000 - on_time
pauseus off_time
next on_time
high Green
pause speed
pause speed
pause speed
pause speed
pause speed
pause speed
RedOff:
for on_time = 0 to 5000 step 10
pulsout Red ,on_time
off_time = 5000 - on_time
pauseus off_time
next on_time
low Red
pause speed
pause speed
pause speed
pause speed
pause speed
pause speed
BlueOn:
for on_time = 0 to 5000 step 1000
pulsout Blue,on_time
off_time = 5000 - on_time
pauseus off_time
next on_time
high Blue
pause speed
pause speed
pause speed
pause speed
pause speed
pause speed
GreenOff:
for on_time = 0 to 5000 step 10
pulsout Green ,on_time
off_time = 5000 - on_time
pauseus off_time
next on_time
low Green
pause speed
pause speed
pause speed
pause speed
pause speed
pause speed
goto main
interrupt:
if pinc.3 = 1 then
do while pinc.3 = 1 : loop ' wait for release
b0 = b0 + 1 // 7 ' 0 to 6
endif
setint %00001000, %00001000
do
for b1 = 1 to b0
pause 1000
high Red
high Blue
high Green
pause 2000
low Red
low Blue
low Green
pause 1000
next b1
exit
loop
return