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

92                        7. USING THE Mbed WITH SIMPLE PROJECTS

                        /*******************************************************************
                                            EXTERNAL FLASHING LED
                                            =====================
                        In this project an external LED is connected to GPIO port pin 10
                        of PORT C (PC_10) through a 390 ohm current limiting resistor. The
                        program flashes the LED quickly such that the ON time is 0.1 second
                        and the OFF time is 1 second. The net result is that the LED flashes
                        quickly
                        Author: Dogan Ibrahim
                        Date  : August 2018
                        File  : ExtLED
                        *********************************************************************/
                        #include "mbed.h"
                        DigitalOut LED(PC_10);                      // External LED at PC_10

                        #define ON 1                                // ON = 1
                        #define OFF 0                               // OFF = 0
                        #define ONTime 0.1                          // ONTime = 0.1s
                        #define OFFTime 1.0                         // OFFTime = 1.0s

                        int main()
                        {
                            while(1)                                // DO FOREVER
                            {
                                LED = ON;                           // LED ON
                                wait(ONTime);                       // Wait ONTime seconds
                                LED = OFF;                          // LED OFF
                                wait(OFFTime);                      // Wait OFFTime seconds
                            }
                        }
                 FIG. 7.23  Program listing.

                                      7.7 PROJECT 4—ROTATING LEDs


                 7.7.1 Description
                   In this project 8 external LEDs are connected to PORT C the Nucleo-F411RE development
                 board. The LEDs turn ON/OFF in a rotating manner every second where only one LED is ON
                 at any time. Fig. 7.24 shows the LED pattern.



                 7.7.2 Aim

                   The aim of this project is to show how external LEDs can be connected to the Nucleo-
                 F411RE board.
   101   102   103   104   105   106   107   108   109   110   111