The bear
Senior Member
Hi Everyone,
What I'm trying to do, with For ..next, is to switch on a light for approx. 3 mins.
Then the succeeding For ..next, switch off the light for a long period, approx. 2hours.
The program times have been reduced, for testing the code.
What is happening, the light (LED) is flashing on & off with the counter, I need it to stay on
until the counter has finished. Works fine in the simulator 6.0.7.3
Regards, Bear..
What I'm trying to do, with For ..next, is to switch on a light for approx. 3 mins.
Then the succeeding For ..next, switch off the light for a long period, approx. 2hours.
The program times have been reduced, for testing the code.
What is happening, the light (LED) is flashing on & off with the counter, I need it to stay on
until the counter has finished. Works fine in the simulator 6.0.7.3
Regards, Bear..
Code:
#Picaxe 14M2 ;08M2
#No_data
LET dirsC =0000111
let dirsB =0011111
SYMBOL SWITCH_ER = C.2
SYMBOL SEN_SOR = C.4
SYMBOL ADC_VAL = b0
SYMBOL COUNTER = b1
MAIN:
ReadADC C.4, ADC_VAL
if ADC_VAL > 80 then gosub STAND_BY
PAUSE 500
if ADC_VAL < 80 then gosub LIGHT_ON
GOTO MAIN
LIGHT_ON:
FOR COUNTER = 1 TO 3
HIGH SWITCH_ER ;LIGHT ON short period
PAUSE 1000 ;60000 x 3 = 3min
NEXT COUNTER
FOR COUNTER = 1 TO 5 ;60000 x 120 = 2hrs
LOW SWITCH_ER ;LIGHT OFF long period
PAUSE 1000 ;60000 = 1min
NEXT COUNTER
RETURN
STAND_BY:
PAUSE 1000
RETURN
Last edited: