35
PICAXE-08 ALARM PROJECT
revolution
© copyright 2002 - AXE102 Alarm Student Project Notes Version 1.1
Revolution Education Ltd. Email: [email protected] Web: www.rev-ed.co.uk
35
Supported by:
Step 8 – Test the LDR
Connect an LDR to the analogue input.
Type in and download the following
program.
main:
readadc 1,b1
if b1 > 100 then do4
if b1 > 50 then do0
low 0
low 4
goto main
do4:
high 4
low 0
goto main
do0:
high 0
low 4
goto main
Note: it may be necessary to alter the threshold values if the room is dark e.g. try 60 and
30 instead of 100 and 50.
The LED and output should come on at different times as you raise and lower your hand
over the LDR (so that different amounts of light fall on the LDR). If they do not check
that the LDR and 1k resistor are correctly soldered.
If all these tests pass, you can be congratulated as you have correctly built and
assembled your alarm! It is now time to develop and test your own program to
operate your alarm system.
start
readadc 1,b1
b1> 100
Y
N
b1> 50
Y
N
high 0
high 4
low 0
low 4
low 4
low 0