User manual

34
Change the count variable to value 4 and test the programme again. Now the LEDs will flash
precisely five times.
You can also use the count loop so that you will not jump back, but forwards. This time, the
process is actually performed five times when C has been loaded with the value 5 in the
beginning. The skipped address 04 contains a relative jump to itself and thus an endless loop
that serves as the programme end.
Address
Command
Data
Comment
00
4
5
A = 5
01
5
2
C = A
02
8
0
AdrHi = 0
03
A
5
C-times 05
04
3
0
End
05
1
5
Port = 0101
06
2
8
Wait for 500 ms
07
1
A
Port = 1010
08
2
8
Wait for 500 ms
09
3
6
Jump –6
45 52 80 A5 30 15 28 1A 28 36
Listing 18: Five flashes
15 Comparisons
Two number values are to be compared. Depending on the result of the comparison, a jump is
performed. The two number values must be in A and B. The following example loads B with the
number 5. A receives its result from the analogue input AD1. Here, e.g. a light sensor can be
connected as in chapter 4. The programme should now perform the following action continually:
If AD1 > 5
then: all LEDs on
else: all LEDs off
All in all, you will receive a twilight switch. Since LDR is connected against GND, more
brightness causes a lower voltage at AD1. The LEDs will go out once a certain brightness sis
exceeded and a certain voltage therefore undercut. The limit is at 6, since the measuring result
must be above 5.
Address
Command
Data
Comment
00
4
5
A = 5
01
5
1
B = A