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

128                       7. USING THE Mbed WITH SIMPLE PROJECTS

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

                                   7-SEGMENT LED COUNTER
                                   =====================
                       In this evrsion of teh program a function is used to display the number

                       Author: Dogan Ibrahim
                       Date  : August 2018
                       File  : SevenSeg-3
                       ************************************************************************/
                       #include "mbed.h"

                       PortOut Segments(PortC, 0xFF);
                       int LEDS[] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
                       //
                       // This function displays number N on the 7-Segment LED
                       //
                       void Display(int N)
                       {
                           Segments = LEDS[N];
                       }

                       //
                       // MAIN program
                       //
                       int main()
                       {
                           int CNT = 0;

                           while(1)
                           {
                               Display(CNT);
                               wait(1.0);
                               CNT++;
                               if(CNT == 10)CNT = 0;
                           }
                       }
                 FIG. 7.74  Another modified program.




                 7.16.11 Suggestions for Additional Work

                   Modify the program given in Fig. 7.72 to display letters L and E alternately on the
                 7-segment display.
   137   138   139   140   141   142   143   144   145   146   147