User manual

35
02
8
0
AdrHi = 0
Address
Command
Data
Comment
03
6
9
A = AD1
04
C
1
Skip if A>B
05
9
8
Adr 08
06
1
F
LEDs 1111
07
3
4
Adr 03
08
1
0
LEDs 0000
09
3
6
Adr 03
45 51 80 69 C1 98 1F 34 10 36
Listing 19: Simple twilight switch
Test the programme by shading the light senor with your hand more or less. You will find that
the basic function is met. However, there is usually an unpleasant side effect. Exactly at the
threshold between On and Off, the LEDs will flash uncontrolledly. Especially in artificial light, the
brightness will fluctuate around a certain average quickly. This flickering is correctly evaluated
by the programme, but the result is not what you would expect of a twilight switch. Chapter 18
shows an improved twilight switch.
16 AND, OR and XOR
Two binary conditions can be linked into a new condition. One example is the AND function:
When bit 1 has condition 1 AND bit 2 has condition 1, the output condition is also 1. Binary
numbers with several bits can also be linked in this manner. The link "10 AND 3 = 2" becomes
understandable when writing it in binary numbers:
1010 AND
0011 =
0010
The following programme links the input conditions to the constant number 3. The AND function
practically causes the two lower bits to be masked (filtered out). In the quiescent condition, the
input port has condition 1111. The AND link with 0011 then delivers the condition 0011 at the
LED. If you connect one of the inputs E1 or E2 to GND, however, the 0 condition is also visible
at the other outputs. Changes to E3 and E4 have no effects.
Address
Command
Data
Comment
00
6
4
A = Din
01
5
1
B = A
02
4
3
A = 3