
Code:
'This routine is how I calibrate my light detector circuit (shown above). I put the circuit outside and count
'the LED flashes when its just too dark for pics. I use this for movie mode. Here's what
'you will see. At startup, there will be 10 quick flashes. This lets you know you are
'beginning. Then there is a pause for 2.3 seconds. Then the number of flashes for the
'hundreds digit take place. Then 3 quick flashes tell you the next is tens digit. Then
'3 quick flashes and the ones digit.
'EXAMPLE #1: Light level measures 214
' 10 quick flashes, 2.3 second delay,2 longer flashes (100s),3 quick flashes, 1 longer flash (10s)
' 3 quick flashes, 4 longer flashes, 3 quick flashes, then 5 second pause. REPEAT
'
'EXAMPLE #2: Light level measures 072
' 10 quick flashes, 2.3 second delay,0 longer flashes (100s),3 quick flashes, 7 longer flash (10s)
' 3 quick flashes, 2 longer flashes, 3 quick flashes, then 5 second pause. REPEAT
low 4
input 2
b0 = 0
b1 = 0
Do
for b5 = 1 to 10 'this routine gives 10 quick flashes
high 4
pause 100
low 4
pause 100
next b5
sleep 1 '2.3 second wait
readadc 2,b1 'read light level on pin2
'b1 = 154 'change the value to test
if b1 > 99 then 'hundreds digit flash
b1 = b1 - 100
high 4
pause 300
low 4
pause 300
end if
if b1 > 99 then 'hundreds digit flash
b1 = b1 - 100
high 4
pause 300
low 4
pause 300
end if
gosub quickflash '3 quick flashes to indicate hundreds digit done
if b1 > 9 then 'tens digit flash
do until b1 < 10
b1 = b1 - 10
high 4
pause 300
low 4
pause 300
loop
end if
gosub quickflash '3 quick flashes to indicate tens digit done
if b1 > 0 then 'ones digit flash
do until b1 < 1
b1 = b1 - 1
high 4
pause 300
low 4
pause 300
loop
end if
gosub quickflash ''3 quick flashes to indicate ones digit done
sleep 2
loop
quickflash:
pause 1000 '1 second pause
for b5 = 1 to 3 '3 quick flashes
high 4
pause 100
low 4
pause 100
next b5
pause 1000 '1 second pause
return