I have written a routine for a PICAXE 08 to flash of two strobe lights on a model aircraft -- double-flashes at about 1-second intervals. The code is:-
The reason for incrementing two variables is so that I can stagger the flashes slightly, as you often see on real aircraft.
I've written another routine that, when it gets a signal from a radio-control receiver, will switch "landing lights" on and off. The code for this is:-
My problem is, when I combine the functions by inserting the landing lights code into the strobe loop, (a) it slows the sequence down by about a factor of 3 and (b) it hangs if there is no signal from the receiver
I can sort the first problem by reducing the values of the constants to compensate for the slower running, but is there any simple way that I can detect a no-signal situation? I would have thought it's the same as pulsin = 0, but that seems not to be the case because that situation is already covered by w1<150.
Code:
main:
let b2= 0
let b0= 0
start_loop: if b2= 0 or b2= 12 then green_on
label_02: if b0= 0 or b0= 12 then red_on
label_03: if b2= 3 or b2= 15 then green_off
label_04: if b0= 3 or b0= 15 then red_off
label_05: let b2=b2+ 1
let b0=b0+ 1
if b0> 200 then red_reset
label_06: if b2> 205 then green_reset
label_07: pause 0
goto start_loop
green_reset: let b2= 0
goto label_07
green_on: high 2
goto label_02
green_off: low 2
goto label_04
red_on: high 0
goto label_03
red_off: low 0
goto label_05
red_reset: let b0= 0
goto label_06
I've written another routine that, when it gets a signal from a radio-control receiver, will switch "landing lights" on and off. The code for this is:-
Code:
main:
label_1F: pulsin 3,1,w1
if w1< 150 then label_11
high 0
goto label_1F
label_11: low 0
goto label_1F
I can sort the first problem by reducing the values of the constants to compensate for the slower running, but is there any simple way that I can detect a no-signal situation? I would have thought it's the same as pulsin = 0, but that seems not to be the case because that situation is already covered by w1<150.