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

102                       7. USING THE Mbed WITH SIMPLE PROJECTS

                         /***********************************************************

                                     RANDOMLY FLASHING LEDs
                                     ======================
                         In this version of teh program the delay between the outputs
                         is random and varies between 0 and 300ms.

                         Author: Dogan Ibrahim
                         Date  : August 2018
                         File  : Christmas-2
                         *************************************************************/
                         #include "mbed.h"
                         BusOut LEDS(PC_0,PC_1,PC_2,PC_3,PC_4,PC_5,PC_6,PC_7);


                         int main()
                         {
                             int Number, Tim;
                             float Del;

                             while(1)
                             {
                                 Number = rand() % 256;              // Random number 0-255
                                 Tim = rand() % 11;                  // Random number 0 - 10
                                 Del = Tim *0.03;                    // Random delay 0-300ms
                                 LEDS = Number;                      // Turn ON LEDs
                                 wait(Del);                          // Random delay
                             }
                         }

                 FIG. 7.37  Modified program.



                         7.10 PROJECT 7—LED CONTROL WITH PUSH-BUTTON

                 7.10.1 Description

                   In this project the user push-button and the user LED on the Nucleo-F411RE development
                 board are used. The LED flashes 3 times when the button is pressed.



                 7.10.2 Aim
                   The aim of this project is to show how the user push-button on the Nucleo board can
                 be used.
   111   112   113   114   115   116   117   118   119   120   121