18
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
18
Supported by:
Using LDRs.
A LDR can be used in two ways. The simplest way to use an LDR is
as a simple on-off ("digital") switch - when the light level is above
a certain value (called the 'threshold value') the LDR will provide
an on signal, when the light level is below a certain value the LDR
will provide an off signal.
In this case the LDR is used in a potential divider with a standard
resistor. The value of the standard resistor sets the 'threshold value'.
For miniature LDRs a suitable value is 10k or 1k, for larger ORP12
type LDRs 10k is more appropriate. If desired the fixed resistor can
be replaced by a variable resistor so that the threshold value can be
'tuned' to different light values.
A more versatile way of using the LDR is to measure a number of different light values, so
that decisions can be made at varying light levels rather than just one fixed threshold
value. A varying value is known as an 'analogue' value, rather than a digital 'on-off' value.
To measure analogue values the microcontroller must contain an 'analogue to digital
converter (ADC)' and the programming software must support use of this ADC. Most
microcontrollers only contain ADC on certain input pins, and so the input pin
connection must be carefully selected. With the 8 pin microcontroller only pin1 can be
used.
The electronic circuit for using the ADC is a potential divider identical to the circuit
above. The analogue 'measurement' is carried out within the microcontroller itself.
10k