Page 101 - ARM Based Microcontroller Projects Using MBED
P. 101
7.5 PROJECT 2—LED FLASHING AS MORSE CODE SOS 87
7.4.7 Suggestions for Additional Work
Modify the program in Fig. 7.12 so that the LED ON time is 2s, and the OFF time is 0.5s.
The User LED is connected to bit 5 of Port A (PA_5). Modify the program in Fig. 7.12 by
replacing LED1 with PA_5.
7.5 PROJECT 2—LED FLASHING AS MORSE CODE SOS
7.5.1 Description
In this project the user LED on the Nucleo-F411RE board is flashed as Morse code SOS. The
SOS Morse code is "...—...". In this project, a dot is represented with the LED being ON for
0.25s (Dot time) and a dash is represented with the LED being ON for 1s (Dash time). The
delay between the dots and dashes is set to 0.2s (GAP time). This process is repeated contin-
uously after 2s of delay.
7.5.2 Aim
The aim of this project is to show how for loops can be used in a program. Additionally, the
program shows how to use the #define statements in Mbed programs.
7.5.3 Block Diagram
The block diagram of the project is shown in Fig. 7.9.
7.5.4 PDL of the Project
The PDL of the project is shown in Fig. 7.16.
7.5.5 Program Listing
The program listing is shown in Fig. 7.17 (program: sos). At the beginning of the program
comment lines are used to describe the operation of the program. Then mbed.h is included
and user LED is configured as output and is assigned to name LED. The Dot, Dash, and Gap
times and also ON and OFF are defined at the beginning of the program. The remainder of the
program is executed in an endless loop created using a while statement. Inside this loop, two
BEGIN
Configure the User LED as output
DO FOREVER
Flash the LED 3 times with Dot time
Wait 0.5 second
Flash the LED 3 times with Dash time
Wait 2 seconds
ENDDO
END
FIG. 7.16 PDL of the project.