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

216                          8. INTERMEDIATE LEVEL PROJECTS

                      //
                      // Read the output voltage of the LDR, then calculate the resistance
                      // of it and finally calculate and display the light level in lux
                      //
                         while(1)                                          // Do forever
                         {
                             mV = 3300.0f * LDR.read();                    // In mV
                             R = 10.0 * mV / (3300.0 - mV);                // LDR resistance
                             lux = 2.17 - 1.28 * log10(R);                 //
                             lux = pow(10.0, lux);                         // Light level (Lux)
                             gotoscr('4', '0');                            // Line 4, col 0
                             MyPC.printf("Light Level (lux) = %5.2f", lux);

                             wait(1.0);                                    // Wait 1 second
                         }
                      }

                 FIG. 8.83,  CONT’D










                 FIG. 8.84  Typical display of the light level.

                 8.25.2 Aim

                   The aim of this project is to show how the flashing rate of the User LED can be changed by
                 using a potentiometer.

                 8.25.3 Block Diagram

                   The block diagram of the project is shown in Fig. 8.85.





















                 FIG. 8.85  Block diagram of the project.
   225   226   227   228   229   230   231   232   233   234   235