Page 184 - ARM Based Microcontroller Projects Using MBED
P. 184

170                          8. INTERMEDIATE LEVEL PROJECTS

                             switch (operation)
                             {
                                 case '+':                                    // If addition
                                     result = first + second;
                                     break;
                                 case '-':                                    // If subtraction
                                     result = first - second;
                                     break;
                                 case '*':                                    // If multiplication
                                     result = first * second;
                                     break;
                                 case '/':                                    // If division
                                     result = first / second;
                                     break;
                             }

                             printf("\n\rResult = %f\n", result);             // Display result
                             wait(5.0);                                       // Wat 5 seconds
                         }
                     }
                 FIG. 8.29,  CONT’D
















                 FIG. 8.30  Typical display from the program.


                 8.11.2 Aim

                   The aim of this project is to show how the various serial communication functions and con-
                 trol codes can be used in a program.


                 8.11.3 The PDL

                   The PDL of the program is very simple and is given in Fig. 8.31.


                 8.11.4 Program Listing
                   Fig. 8.32 shows the program listing (program: Timestable). At the beginning of the pro-
                 gram, the functions to clear the screen and home the cursor are defined. The program then
   179   180   181   182   183   184   185   186   187   188   189