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

8.24  PROJECT 20—LIGHT LEVEL METER                213
              The resistance of the LDR is calculated as:
              Assuming that R is the resistance used and the resistance of the LDR is R L ,

                                                   3300R L
                                               V ¼                                       (8.1)
                                                    R + R L
            where V is the voltage measured across the LDR (in mV). The LDR resistance is then found as

                                                     VR
                                              R L ¼                                      (8.2)
                                                   3300 V
            R is 10K, therefore, the equation becomes
                                                     10V
                                              R L ¼                                      (8.3)
                                                   3300 V
            where R L is the measured LDR resistance in kilo-ohms and V o is in millivolts.
              The relationship between the LDR resistance of the NORPS-12 and the illumination is
            given approximately by

                                     Log 10 LðÞ ¼ 2:17 1:28 Log 10 R L Þ                 (8.4)
                                                                ð
              where L is the illumination in lux and R L is as before (i.e., the LDR resistance in kilo-ohms).
            Therefore, we can first find the resistance R L using Eq. (8.3). Then, we can calculate the illu-
            mination L from Eq. (8.4).



            8.24.5 The Construction

              The project is constructed on a breadboard as shown in Fig. 8.81.


            8.24.6 The PDL

              Fig. 8.82 shows the program PDL.


            8.24.7 Program Listing

              Fig. 8.83 shows the program listing (program: LDR). At the beginning of the program, a
            heading is displayed. The program then reads the voltage across the LDR and stores in var-
            iable mV. The resistance of the LDR is then calculated and stored in variable R. The program
            finally calculates the light level in lux and displays it at line 4, column 0 of the PC screen. The
            display is refreshed every second. Fig. 8.84 shows a typical display of the light level. Notice
            that it will be required to calibrate the readings for accurate measurements using a profes-
            sional light level meter.
              Notice that function log10 calculates the logarithm to base 10 of the given number. There is
            no antilogarithm function in Mbed. But since antilogarithm is same as raising 10 to the power
            of the given number, the pow() function is used to calculate the antilogarithm and hence the
            ambient light level.
   222   223   224   225   226   227   228   229   230   231   232