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

194                          8. INTERMEDIATE LEVEL PROJECTS















                 FIG. 8.55  Block diagram of the project.



                 8.20.4 The PDL

                   Fig. 8.56 shows the program PDL.



                 8.20.5 Program Listing

                   Fig. 8.57 shows the program listing (program: Voltmeter). At the beginning of the pro-
                 gram, analog port ADC1/0 is configured as analog input using the statement AnalogIn.
                 The program executes in an endless loop formed using a while statement. Inside this loop,
                 the voltage is read using the read() statement which returns a floating point data in the range
                 0.0–1.0. With a 3.3V ADC reference voltage, 0.0 corresponds to 0V and 1.0 corresponds to
                 +3.3V. The actual analog voltage in millivolts is found by multiplying the data read by
                 3300. This value is then converted into real physical voltage and stored as millivolts in var-
                 iable mV. This value is then displayed on the PC screen. This process is repeated every sec-
                 ond. Fig. 8.58 shows a typical output from the program.




                          BEGIN
                                 Clear the screen and home the cursor
                                 Display heading
                                 DO FOREVER
                                        Read the analog input voltage as digital value
                                        Convert the reading into voltage in mV
                                        Display the voltage in mV
                                        Wait one second
                                 ENDDO
                          END
                 FIG. 8.56  Program PDL.
   203   204   205   206   207   208   209   210   211   212   213