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

294                      10. USING LIQUID CRYSTAL DISPLAYS (LCDs)


























                 FIG. 10.14  Program PDL.

                   Function CalculateDistance sends a 10μs trigger pulse to the sensor module and resets the
                 Timer to 0. When the echo signal falls LOW the duration of the echo signal is read and stored
                 in floating point variable EchoDuration. The distance to the head of the person is then cal-
                 culated in centimeters and is returned to the main program.
                   The height of the person is displayed in the following format:

                   nnn.nncm


                 10.4.7 Suggestions for Additional Work
                   Modify the project to measure the distance to an object and display it on an LCD.



                           10.5 PROJECT 4—CALCULATOR USING A KEYPAD

                 10.5.1 Description

                   In this project a basic four-function integer calculator is designed using a 4 4 keypad. The
                 calculator can perform addition, subtraction, multiplication, and division. The calculator
                 operates in Reverse Polish Notation (RPN) where the first number is entered, followed by
                 the Enter key, the second number is entered again followed by the Enter key, then the re-
                 quired operation is entered. The result is displayed on the LCD.
                   The heading CALCULATOR is displayed at column 0, row 0 of the LCD for 2s. As an ex-
                 ample, the following steps are required to add numbers 20 and 10 (characters typed by the
                 user are in bold for clarity). The result is displayed for 5s and then the LCD is cleared, ready
                 for the next calculation:
   303   304   305   306   307   308   309   310   311   312   313