User manual
the new reference point for continuous measurements.
We therefore compare a fixed light value that is measured anew
every 10 seconds to the light value of the continuous meas-
urement. The defined threshold will only cause the alarm to be
tripped if the current light value +/- exceeds or undercuts the
threshold.
001 cnt++;
002 if(cnt > 2000)
003 {
004 cnt = 0;
005 value = analogRead(PHOTOTRANSITOR)
006 }
If the variable
cnt
is above 2,000, a new value will be read from
the analogue input A0. An inserted pause that influences the
program run speed will only increment the variable
cnt
by 1 every
5 ms. This leads to a value of 5 ms x 2,000 = 10,000 ms = 10
seconds.
001 Threshold = 25
002 if(analogRead(PHOTOTRANSITOR) > (value + Threshold) ||
analogRead(PHOTOTRANSITOR) < (value – Threshold))
Here, the value of the variable named
Threshold
is set. It is
responsible for trigger sensitivity and should not be set too
high or too low, since the alarm system will either barely react
at all or trigger too many false alarms otherwise. The evaluation
of the continuous measured value that is recorded every 5 ms will
take place in this program row.
To test this, run your hand over the phototransistor at a distance
of approx. 50 cm in a normally lit room. the alarm will trip.
This can even be done very quickly. The detector will record you
at once if darkening by your hand exceeds 5 ms.
The alarm system could also be placed in a refrigerator and add
a counter variable to the alarm message, to record the opening
cycles of the refrigerator. In the refrigerator experiment, you
will find that the LCD will change its contrast and will also
turn very idle. Just try it out.
We use the same setup as for the photometer light meter!
001 // Integrating LCD-Library