by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

Committer:
robt
Date:
Fri Aug 31 15:25:02 2012 +0000
Revision:
0:0e32344cdb26
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
robt 0:0e32344cdb26 1 /*Program Example 3.5: Simple demonstration of 7-segment display. Display digits 0, 1, 2, 3 in turn.
robt 0:0e32344cdb26 2 */
robt 0:0e32344cdb26 3 #include "mbed.h"
robt 0:0e32344cdb26 4 BusOut display(p5,p6,p7,p8,p9,p10,p11,p12); // segments a,b,c,d,e,f,g,dp
robt 0:0e32344cdb26 5
robt 0:0e32344cdb26 6 int main()
robt 0:0e32344cdb26 7 {
robt 0:0e32344cdb26 8 while(1) {
robt 0:0e32344cdb26 9 for(int i=0; i<4; i++) {
robt 0:0e32344cdb26 10 switch (i) {
robt 0:0e32344cdb26 11 case 0:
robt 0:0e32344cdb26 12 display = 0x3F;
robt 0:0e32344cdb26 13 break; //display 0
robt 0:0e32344cdb26 14 case 1:
robt 0:0e32344cdb26 15 display = 0x06;
robt 0:0e32344cdb26 16 break; //display 1
robt 0:0e32344cdb26 17 case 2:
robt 0:0e32344cdb26 18 display = 0x5B;
robt 0:0e32344cdb26 19 break;
robt 0:0e32344cdb26 20 case 3:
robt 0:0e32344cdb26 21 display = 0x4F;
robt 0:0e32344cdb26 22 break;
robt 0:0e32344cdb26 23 } //end of switch
robt 0:0e32344cdb26 24 wait(0.2);
robt 0:0e32344cdb26 25 } //end of for
robt 0:0e32344cdb26 26 } //end of while
robt 0:0e32344cdb26 27 } //end of main
robt 0:0e32344cdb26 28