User manual

38
18 Twilight Switch
A twilight switch is to switch on the lamp when the ambient brightness drops below a certain
limit. When the light grows brighter, the lamp is to go out again. It should be ensured that the
light does not flicker on the threshold between light and dark. This is possible with a hysteresis,
i.e. a certain distance between the activation and deactivation brightness. The programme
presented here works with the following rules:
If the voltage at AD1 is not above 5, the lamp is switched off.
If the voltage at AD1 is not below 9, the lamp is switched on.
This provides a middle area in which the output condition cannot change. This gap prevents
flickering of the LEDs.
0–5: LEDs off
6–8: LEDs unchanged
9–15: LEDs on
Address
Command
Data
Comment
00
1
0
LEDs 0000
01
4
5
A = 5
02
5
1
B = A
03
6
9
A = AD1
04
C
1
Skip if A>B
05
1
0
LEDs 0000
06
4
9
A = 9
07
5
1
B = A
08
6
9
A = AD1
09
C
2
Skip if A<B
0A
1
F
LEDs 1111
0B
3
A
Jump 10
10 45 51 69 C1 10 49 51 69 C2 1F 3A
Listing 23: Twilight switch with hysteresis
19 LED-Dimmer
The target of this programming example is a controllable LED lamp. The brightness of an LED at
the PWM output is to be adjustable via buttons. You can briefly push a button to get to the next
brightness stage, or you can keep pushing to change the brightness continually.