Page 182 - ARM Based Microcontroller Projects Using MBED
P. 182
168 8. INTERMEDIATE LEVEL PROJECTS
BEGIN
DO FOREVER
Clear the screen and home the cursor
Enter the first number
Enter the second number
Enter the required operation
Calculate and display the result
Wait 5 seconds
ENDDO
END
FIG. 8.28 Program PDL.
8.10.4 Program Listing
Fig. 8.29 shows the program listing (program: Calculator). At the beginning of the pro-
gram, the functions to clear the screen and home the cursor are defined. Inside the main pro-
gram an infinite loop is formed using a while statement. The two numbers and the required
operation (+ - * /) are read from the keyboard. The result is displayed on the PC screen for 5s
and then the above process is repeated. Fig. 8.30 shows a typical display from the program
where two numbers are multiplied and the result is displayed.
8.11 PROJECT 8—LEARN YOUR TIMES TABLES
8.11.1 Description
This program makes learning the times tables fun. The program asks for a number and
then displays the times table for that number from 1 to 12. For example, if the entered number
is 5, the program will display the following:
TIMES TABLE FOR 5
¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼¼
5x1 ¼ 5
5x2 ¼ 10
5x3 ¼ 15
5x4 ¼ 20
5x5 ¼ 25
5x6 ¼ 30
5x7 ¼ 35
5x8 ¼ 40
5x9 ¼ 45
5x10 ¼ 50
5x11 ¼ 55
5x12 ¼ 60