Hello. There is a 12 led night lamp with a touch switch. (2 chips 20m2). Every led is an independent task. Is there a way to turn off all of them at the same time after a period of time (30 min.) to save battery (4AA)
Thank you very much
.
Here is the code
#PICAXE 20M2
#NO_DATA
; works. turn on off the led when touch. Turn all led off after 30 minutes (1800000ms)
symbol V_med = 5200 ;long wires
symbol pause1 = 300
main:
start0:
touch16 B.6,w0 ; read value into w0
if w0 > V_med then
high C.0
pause pause1 ;delay to have a time for finger to be detached from the button
high C.0
end if
touch16 B.6,w0 ; read value into w0
if w0 > V_med then
low C.0
pause pause1 ;delay to have a time for finger to be detached from the button
low C.0
end if
goto start0
start1:
touch16 B.5,w1 ; read value into w1
if w1 > V_med then
high C.1
pause pause1
high C.1
end if
touch16 B.5,w1 ; read value into w1
if w1 > V_med then
low C.1
pause pause1
low C.1
end if
goto start1
start2:
touch16 B.4,w2 ; read value into w2
if w2 > V_med then
high C.2
pause pause1
high C.2
end if
touch16 B.4,w2 ; read value into w2
if w2 > V_med then
low C.2
pause pause1
low C.2
end if
goto start2
start3:
touch16 B.3,w3 ; read value into w3
if w3 > V_med then
high C.3
pause pause1
high C.3
end if
touch16 B.3,w3 ; read value into w3
if w3 > V_med then
low C.3
pause pause1
low C.3
end if
goto start3
start4:
touch16 B.2,w4 ; read value into w4
if w4 > V_med then
high C.4
pause pause1
high C.4
end if
touch16 B.2,w4 ; read value into w4
if w4 > V_med then
low C.4
pause pause1
low C.4
end if
goto start4
start5:
touch16 B.1,w5 ; read value into w5
if w5 > V_med then
high C.5
pause pause1
high C.5
end if
touch16 B.1,w5 ; read value into w5
if w5 > V_med then
low C.5
pause pause1
low C.5
end if
goto start5
goto main
Thank you very much
.
Here is the code
#PICAXE 20M2
#NO_DATA
; works. turn on off the led when touch. Turn all led off after 30 minutes (1800000ms)
symbol V_med = 5200 ;long wires
symbol pause1 = 300
main:
start0:
touch16 B.6,w0 ; read value into w0
if w0 > V_med then
high C.0
pause pause1 ;delay to have a time for finger to be detached from the button
high C.0
end if
touch16 B.6,w0 ; read value into w0
if w0 > V_med then
low C.0
pause pause1 ;delay to have a time for finger to be detached from the button
low C.0
end if
goto start0
start1:
touch16 B.5,w1 ; read value into w1
if w1 > V_med then
high C.1
pause pause1
high C.1
end if
touch16 B.5,w1 ; read value into w1
if w1 > V_med then
low C.1
pause pause1
low C.1
end if
goto start1
start2:
touch16 B.4,w2 ; read value into w2
if w2 > V_med then
high C.2
pause pause1
high C.2
end if
touch16 B.4,w2 ; read value into w2
if w2 > V_med then
low C.2
pause pause1
low C.2
end if
goto start2
start3:
touch16 B.3,w3 ; read value into w3
if w3 > V_med then
high C.3
pause pause1
high C.3
end if
touch16 B.3,w3 ; read value into w3
if w3 > V_med then
low C.3
pause pause1
low C.3
end if
goto start3
start4:
touch16 B.2,w4 ; read value into w4
if w4 > V_med then
high C.4
pause pause1
high C.4
end if
touch16 B.2,w4 ; read value into w4
if w4 > V_med then
low C.4
pause pause1
low C.4
end if
goto start4
start5:
touch16 B.1,w5 ; read value into w5
if w5 > V_med then
high C.5
pause pause1
high C.5
end if
touch16 B.1,w5 ; read value into w5
if w5 > V_med then
low C.5
pause pause1
low C.5
end if
goto start5
goto main