Hello,
And thank you in advance to all. This code works fine but in some cases fail. An expert who know how to improve some details like add some pauses or something to make it stable that want to help me?.
I am learning a lot but I know that there are people who knows the pros and cons or tricks that the picaxe have.
One of the issues is that sometimes when the pic is running outside of the loop and then the condition b0 < 9 is fulfilled, the code don't jump to sub1...
Thank you guys!!!
Code:
And thank you in advance to all. This code works fine but in some cases fail. An expert who know how to improve some details like add some pauses or something to make it stable that want to help me?.
I am learning a lot but I know that there are people who knows the pros and cons or tricks that the picaxe have.
One of the issues is that sometimes when the pic is running outside of the loop and then the condition b0 < 9 is fulfilled, the code don't jump to sub1...
Thank you guys!!!
Code:
Code:
#picaxe 08m2
symbol lightlevel = b0
inmain:
pause 500 ; make a label called inmain
do ; start loop just at start up and while b0 > 9
high B.2 ; switch on 2
readadc C.1, b0 ; read ADC1 into variable b0
debug b0
if b0 < 9 then
exit ; exit the loop when b0 < 9
end if
loop ; loop
main: ; make a label called main
readadc C.1, lightlevel ; read ADC1 into variable b0 named lightlevel
debug b0 ; transmit value to computer screen
pause 500 ; short delay
do
select case lightlevel
case < 9 : if time > 5 and time < 8 then
gosub Sub1
end if
case > 48 : if time > 5 and time < 8 then
gosub sub1
end if
else : time = 0
end select
high B.2 ; else switch on 2
goto main ; jump back to start
loop
sub1: ; make a label
low B.2 ; switch off 2
pause 2000 ; wait 2 seconds to simulate switch
high B.2 ; switch on 2
pause 500
goto main ; jump back to start