Eduvance vanmat
/
06Binary_Display
BinaryOnSeg
Revision 1:725074331ef6, committed 2014-05-27
- Comitter:
- Eduvance
- Date:
- Tue May 27 07:27:47 2014 +0000
- Parent:
- 0:ad2c8f6517f2
- Commit message:
- A
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r ad2c8f6517f2 -r 725074331ef6 main.cpp --- a/main.cpp Mon May 19 10:24:14 2014 +0000 +++ b/main.cpp Tue May 27 07:27:47 2014 +0000 @@ -1,12 +1,189 @@ #include "mbed.h" -DigitalOut myled(LED1); +DigitalIn sw0(p14); +DigitalIn sw1(p15); +DigitalIn sw2(p16); +DigitalIn sw3(p17); + +BusOut Disp(p26,p25,p24,p23,p22,p21,p20); // ABCDEFGdp +DigitalOut vdd1(p19); +DigitalOut vdd2(p18); + +void setvdd1() +{vdd1 = 1; +vdd2 =0;} + +void setvdd2() +{vdd1 = 0; +vdd2 = 1;} + +void setvdd() +{vdd1=1; +vdd2=1;} +int i=0; int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); - } + while(1) + { + if (sw0 == 0 && sw1 == 0 && sw2 == 0 && sw3 == 0) + { for (i=0 ; i<10; i++) + {setvdd(); + Disp = 0xC0; + wait(0.01);} + } + + if (sw0 == 0 && sw1 == 0 && sw2 == 0 && sw3 == 1) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xC0; + wait(0.01); + setvdd1(); + Disp = 0xF9; + wait(0.01);} + } + + if (sw0 == 0 && sw1 == 0 && sw2 == 1 && sw3 == 0) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xC0; + wait(0.01); + setvdd1(); + Disp = 0xA4; + wait(0.01);} + } + + if (sw0 == 0 && sw1 == 0 && sw2 == 1 && sw3 == 1) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xC0; + wait(0.01); + setvdd1(); + Disp = 0xB0; + wait(0.01);} + } + + if (sw0 == 0 && sw1 == 1 && sw2 == 0 && sw3 == 0) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xC0; + wait(0.01); + setvdd1(); + Disp = 0x99; + wait(0.01);} + } + + if (sw0 == 0 && sw1 == 1 && sw2 == 0 && sw3 == 1) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xC0; + wait(0.01); + setvdd1(); + Disp = 0x92; + wait(0.01);} + } + + if (sw0 == 0 && sw1 == 1 && sw2 == 1 && sw3 == 0) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xC0; + wait(0.01); + setvdd1(); + Disp = 0x82; + wait(0.01);} + } + + if (sw0 == 0 && sw1 == 1 && sw2 == 1 && sw3 == 1) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xC0; + wait(0.01); + setvdd1(); + Disp = 0xF8; + wait(0.01);} + } + + if (sw0 == 1 && sw1 == 0 && sw2 == 0 && sw3 == 0) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xC0; + wait(0.01); + setvdd1(); + Disp = 0x80; + wait(0.01);} + } + + if (sw0 == 1 && sw1 == 0 && sw2 == 0 && sw3 == 1) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xC0; + wait(0.01); + setvdd1(); + Disp = 0x90; + wait(0.01);} + } + + if (sw0 == 1 && sw1 == 0 && sw2 == 1 && sw3 == 0) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xF9; + wait(0.01); + setvdd1(); + Disp = 0xC0; + wait(0.01);} + } + + + if (sw0 == 1 && sw1 == 0 && sw2 == 1 && sw3 == 1) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xF9; + wait(0.01); + setvdd1(); + Disp = 0xF9; + wait(0.01);} + } + + if (sw0 == 1 && sw1 == 1 && sw2 == 0 && sw3 == 0) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xF9; + wait(0.01); + setvdd1(); + Disp = 0xA4; + wait(0.01);} + } + + if (sw0 == 1 && sw1 == 1 && sw2 == 0 && sw3 == 1) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xF9; + wait(0.01); + setvdd1(); + Disp = 0xB0; + wait(0.01);} + } + + if (sw0 == 1 && sw1 == 1 && sw2 == 1 && sw3 == 0) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xF9; + wait(0.01); + setvdd1(); + Disp = 0x99; + wait(0.01);} + } + + if (sw0 == 1 && sw1 == 1 && sw2 == 1 && sw3 == 1) + { for (i=0 ; i<10; i++) + {setvdd2(); + Disp = 0xF9; + wait(0.01); + setvdd1(); + Disp = 0x92; + wait(0.01);} + } + } + +} +