Page 192 - ARM Based Microcontroller Projects Using MBED
P. 192
178 8. INTERMEDIATE LEVEL PROJECTS
FIG. 8.39 Output from the program.
of the outer loop. It is interesting to note in Fig. 8.38 that the for loop takes 8ms when the
iteration count is 160,000.
Fig. 8.39 shows the output from the program.
8.13.5 Suggestions for Additional Work
Modify the program in Fig. 8.38 so that the program displays the elapsed time when the
inner loop multiplies two integer numbers.
8.14 PROJECT 11—REACTION TIMER
8.14.1 Description
This is a reaction timer project. The User LED on the Nucleo-F411RE board is lit randomly
and the user is expected to press the User button as soon as he/she sees the light coming ON.
The time between seeing the light and pressing the button is displayed in milliseconds on the
PC screen.
8.14.2 Aim
The aim of this project is to show how the Timer function can be used in a project.
8.14.3 The PDL
The PDL of the program is shown in Fig. 8.40.
8.14.4 Program Listing
Fig. 8.41 shows the program listing (program: Reaction). At the beginning of the program,
LED1 and BUTTON1 are defined as digital output and digital input, respectively. Inside the
main program the following heading is displayed:
Reaction timing
Press the button as soon as you see the light…