Axe- LED- Night Light
This is a minimal hardware project!
It is intended to give orientation in a dark room in the night.
The LED has three (!!) functions:
1. Emit light flashes for orientation.
2. Act as reference voltage 1,67V to measure the battery voltage. If the voltage is under a limit value, then double flashes will be sent.
3. Act as light sensor – photo diode and capacity. This capacity is charged first and then will be emptied by the photo current. If the capacity is emptied fast, then no flashes and a longer sleep will occur.
21.10.2007
Have fun with the picaxe!
CWE
' LED Nachtlicht 21.10.2007 C.W.E.
' Nacht- Orientierungslicht betrieben an 2 AA Zellen
' Es wird festgestellt, ob es dunkel ist. Wenn es dunkel ist, dann leuchtet eine LED kurz auf.
' Wenn die Batteriespannung unter 2,25V sinkt, dann Doppelblitz.
' Funktionen der LED:
' 1. Leuchten; 2. Referenzspannung für Batteriespannungsmessung;
' 3. Photodiode, die ihre eigene Kapazität entlädt.
' Eigenschaften Fotodiode: C=20pF, I= 10E-6 A hell, I= 10e-12 A dunkel
' Rote LED
' Spannung an der LED 1,67V: UBat= 1,67/adc*1024
' Const
symbol LLimit = 350 '950
symbol ULimit = 2250 '2250
' Ports
symbol LEDM =1 ' Leg 6 Minuspol der LED
symbol LEDP =2 ' Leg 5 Pluspol der LED
symbol R =4 ' Leg 3 Vorwiderstand zum Pluspol der LED
' Vars
symbol UBat = w6
symbol Light = w5
symbol i = w4
Start:
for i= 1 to 10
low ledm
high r
pause 300
low r
pause 300
next i
high r
readadc10 ledp,w0
Ubat= 42752/w0*40 '167*256/adc*40 Ubat in mV
debug
wait 5
Schleife:
Laden: ' Lichtmessung
low r
high ledm
'pause 10
nap 1
readadc10 ledm,w0
input ledm
messen:
nap 3 '5
readadc10 ledm,Light
debug
if Light>LLimit then 'Dunkel: Licht einschalten
low ledm
high r
readadc10 ledp,w0
Ubat= 42752/w0*40 '167*256/adc*4 Ubat in mV
nap 1
low r
nap 2
if UBat<ULimit then
high r
nap 1
low r
endif
low r ' Diode umpolen für Messung
high ledm
nap 5
else
sleep 10 '*2,3 s
endif
goto Schleife
end
This is a minimal hardware project!
It is intended to give orientation in a dark room in the night.
The LED has three (!!) functions:
1. Emit light flashes for orientation.
2. Act as reference voltage 1,67V to measure the battery voltage. If the voltage is under a limit value, then double flashes will be sent.
3. Act as light sensor – photo diode and capacity. This capacity is charged first and then will be emptied by the photo current. If the capacity is emptied fast, then no flashes and a longer sleep will occur.
21.10.2007
Have fun with the picaxe!
CWE
' LED Nachtlicht 21.10.2007 C.W.E.
' Nacht- Orientierungslicht betrieben an 2 AA Zellen
' Es wird festgestellt, ob es dunkel ist. Wenn es dunkel ist, dann leuchtet eine LED kurz auf.
' Wenn die Batteriespannung unter 2,25V sinkt, dann Doppelblitz.
' Funktionen der LED:
' 1. Leuchten; 2. Referenzspannung für Batteriespannungsmessung;
' 3. Photodiode, die ihre eigene Kapazität entlädt.
' Eigenschaften Fotodiode: C=20pF, I= 10E-6 A hell, I= 10e-12 A dunkel
' Rote LED
' Spannung an der LED 1,67V: UBat= 1,67/adc*1024
' Const
symbol LLimit = 350 '950
symbol ULimit = 2250 '2250
' Ports
symbol LEDM =1 ' Leg 6 Minuspol der LED
symbol LEDP =2 ' Leg 5 Pluspol der LED
symbol R =4 ' Leg 3 Vorwiderstand zum Pluspol der LED
' Vars
symbol UBat = w6
symbol Light = w5
symbol i = w4
Start:
for i= 1 to 10
low ledm
high r
pause 300
low r
pause 300
next i
high r
readadc10 ledp,w0
Ubat= 42752/w0*40 '167*256/adc*40 Ubat in mV
debug
wait 5
Schleife:
Laden: ' Lichtmessung
low r
high ledm
'pause 10
nap 1
readadc10 ledm,w0
input ledm
messen:
nap 3 '5
readadc10 ledm,Light
debug
if Light>LLimit then 'Dunkel: Licht einschalten
low ledm
high r
readadc10 ledp,w0
Ubat= 42752/w0*40 '167*256/adc*4 Ubat in mV
nap 1
low r
nap 2
if UBat<ULimit then
high r
nap 1
low r
endif
low r ' Diode umpolen für Messung
high ledm
nap 5
else
sleep 10 '*2,3 s
endif
goto Schleife
end
Attachments
-
15 KB Views: 137