Taken from the book but for Newbies to compare with a Common Cathode arrangement and different HEX values for the LED's

Dependencies:   mbed

Fork of PE_03-05_SevenSegDisplay by Rob Toulson

main.cpp

Committer:
Degs
Date:
2013-03-13
Revision:
1:5da67a011df5
Parent:
0:0e32344cdb26

File content as of revision 1:5da67a011df5:

/*Program Example 3.5: Simple demonstration of 7-segment display. Display digits 0, 1, 2, 3 in turn.
                                                                       */
#include "mbed.h"
BusOut display(p5,p6,p7,p8,p9,p10,p11,p12);   // segments a,b,c,d,e,f,g,dp

int main()
{
    while(1) {
        for(int i=0; i<10; i++) {
            switch (i) {
                case 0:
                    display = 0xC0;
                    break;       //display 0
                case 1:
                    display = 0xF9;
                    break;       //display 1
                case 2:
                    display = 0xA4;
                    break;
                case 3:
                    display = 0xB0;
                    break;
                case 4:
                    display = 0x99;
                    break; 
                case 5:
                    display = 0x92;
                    break;       //display 0
                case 6:
                    display = 0x82;
                    break;       //display 1
                case 7:
                    display = 0xF8;
                    break;
                case 8:
                    display = 0x80;
                    break;
                case 9:
                    display = 0x90;
                    break;       
            }                                      //end of switch
            wait(1.0);
        }                                        //end of for
    }                                          //end of while
}                                            //end of main