Hello. I tried to reproduce this project of "smart candle" with picaxe. Less pieces and another programming lesson:
(thanks for the author!)
1. So there is a light always on
2. When you blow on the microphone - light goes off for a pause of 5000
3. There is a ldr (with the voltage divider with 10k). You can use a lighter during a pause and the light go on
4. Or the the light go on (after pause 5000)
The question is about the lighting by ldr. I tried to use an interrupt. It doesn’t work. I thought to use the SELECTION and another CASE command. Still the same result. So the question is how to interrupt the light off during the pause by using the LDR. Thank you for some ideas.
(ldr: light - 130 Ohm, dark - 4kOhm)
#PICAXE 18M2
#NO_DATA
symbol V_micro = B.1
symbol d_val = b4
symbol V_ldr = C.1
symbol d_val_ldr = b2
symbol V_min_ldr = 0
symbol V_med_ldr = 25
symbol V_max_ldr = 256
symbol y_led = C.0
symbol V_min = 0
symbol V_med = 25
symbol V_max = 256
main: readadc V_micro, d_val
select d_val
case V_min to V_med
high y_led
case V_med to V_max
low y_led
pause 5000
high y_led
endselect
interrupt: readadc V_ldr, d_val_ldr
if b2 < 1 then interrupt
high C.0
setint %00000010,%00000010,C ; re-activate interrupt
return
goto main
1. So there is a light always on
2. When you blow on the microphone - light goes off for a pause of 5000
3. There is a ldr (with the voltage divider with 10k). You can use a lighter during a pause and the light go on
4. Or the the light go on (after pause 5000)
The question is about the lighting by ldr. I tried to use an interrupt. It doesn’t work. I thought to use the SELECTION and another CASE command. Still the same result. So the question is how to interrupt the light off during the pause by using the LDR. Thank you for some ideas.
(ldr: light - 130 Ohm, dark - 4kOhm)
#PICAXE 18M2
#NO_DATA
symbol V_micro = B.1
symbol d_val = b4
symbol V_ldr = C.1
symbol d_val_ldr = b2
symbol V_min_ldr = 0
symbol V_med_ldr = 25
symbol V_max_ldr = 256
symbol y_led = C.0
symbol V_min = 0
symbol V_med = 25
symbol V_max = 256
main: readadc V_micro, d_val
select d_val
case V_min to V_med
high y_led
case V_med to V_max
low y_led
pause 5000
high y_led
endselect
interrupt: readadc V_ldr, d_val_ldr
if b2 < 1 then interrupt
high C.0
setint %00000010,%00000010,C ; re-activate interrupt
return
goto main