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

100                       7. USING THE Mbed WITH SIMPLE PROJECTS

                 while statement. Inside this loop the value of CNT is sent to PORT C and CNT is then
                 incremented by 1. This process is repeated after 1s delay until CNT is greater than 255
                 (i.e., all LEDS are ON) at which point CNT is reset back to 0.


                                7.9 PROJECT 6—RANDOM FLASHING LEDs


                 7.9.1 Description
                   In this project 8 external LEDs are connected to PORT C the Nucleo-F411RE development
                 board as in the previous project. The LEDs turn ON and OFF randomly so that they look like
                 Christmas light. 250ms delay is inserted in every output.


                 7.9.2 Aim

                   The aim of this project is to show random numbers can be generated in Mbed programs.


                 7.9.3 Block Diagram
                   The block diagram of the project is shown in Fig. 7.25, where 8 LEDs are connected to PORT
                 C pins of the Nucleo-F411RE development board.


                 7.9.4 Circuit Diagram
                   The circuit diagram of the project is shown in Fig. 7.26 where the LEDs are connected using
                 current limiting resistors.


                 7.9.5 The PDL
                   Fig. 7.35 shows the PDL of the program.


                            BEGIN
                                  Group PORT C lower byte
                                  DO FOREVER
                                             Generate a random number between 0 and 255
                                             Send the generated number to PORT C
                                             Wait 250ms
                                  ENDDO
                            END
                 FIG. 7.35  PDL of the program.
   109   110   111   112   113   114   115   116   117   118   119