Page 121 - ARM Based Microcontroller Projects Using MBED
P. 121
7.12 PROJECT 9—BINARY EVENT COUNTING WITH LEDs 107
FIG. 7.43 Block diagram of the project.
FIG. 7.44 Circuit diagram of the project.
7.12.5 The PDL
Fig. 7.45 shows the PDL of the program.
7.12.6 Program Listing
The program listing is shown in Fig. 7.46 (program: Events). At the beginning of the pro-
gram BusOut statement is used to group the PORT C lower byte into a variable called LEDS
and variable Cnt is initialized to 0 and all the LEDs are turned OFF to start with. The remain-
der of the program runs in an endless loop. Inside this loop the state of the button is checked.
If the button is pressed (button is 0) then variable Cnt is incremented by one and the total
count is displayed in binary on the LEDs. The program then waits until the button is released
and the above process is repeated.