Counts 00-99 on Multiplexed Seven Segment Diaplay

Dependencies:   mbed

Committer:
Eduvance
Date:
Tue May 27 07:14:38 2014 +0000
Revision:
1:c94105b8d9b5
Parent:
0:bd8fd0afc24a
Child:
2:00ae261aa180
A

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Eduvance 0:bd8fd0afc24a 1 #include "mbed.h"
Eduvance 0:bd8fd0afc24a 2
Eduvance 1:c94105b8d9b5 3 BusOut Disp(p26,p25,p24,p23,p22,p21,p20); // ABCDEFGdp
Eduvance 1:c94105b8d9b5 4 DigitalOut vdd1(p19);
Eduvance 1:c94105b8d9b5 5 DigitalOut vdd2(p18);
Eduvance 1:c94105b8d9b5 6
Eduvance 1:c94105b8d9b5 7 void show(int m);
Eduvance 1:c94105b8d9b5 8
Eduvance 1:c94105b8d9b5 9 void setvdd1()
Eduvance 1:c94105b8d9b5 10 {vdd1 = 1;
Eduvance 1:c94105b8d9b5 11 vdd2 =0;}
Eduvance 1:c94105b8d9b5 12
Eduvance 1:c94105b8d9b5 13 void setvdd2()
Eduvance 1:c94105b8d9b5 14 {vdd1 = 0;
Eduvance 1:c94105b8d9b5 15 vdd2 = 1;}
Eduvance 1:c94105b8d9b5 16
Eduvance 1:c94105b8d9b5 17 int i = 0;
Eduvance 1:c94105b8d9b5 18 int j = 0;
Eduvance 1:c94105b8d9b5 19 int k = 0;
Eduvance 1:c94105b8d9b5 20 int m = 0;
Eduvance 1:c94105b8d9b5 21 int n = 0;
Eduvance 0:bd8fd0afc24a 22
Eduvance 0:bd8fd0afc24a 23 int main() {
Eduvance 1:c94105b8d9b5 24 while(1){
Eduvance 1:c94105b8d9b5 25 for (i=0; i<=99; i++){
Eduvance 1:c94105b8d9b5 26 j = i / 10;
Eduvance 1:c94105b8d9b5 27 k = i % 10;
Eduvance 1:c94105b8d9b5 28 for(n=0; n<99; n++){
Eduvance 1:c94105b8d9b5 29 setvdd2();
Eduvance 1:c94105b8d9b5 30 show(j);
Eduvance 1:c94105b8d9b5 31 setvdd1();
Eduvance 1:c94105b8d9b5 32 show(k);}
Eduvance 1:c94105b8d9b5 33 }
Eduvance 1:c94105b8d9b5 34
Eduvance 1:c94105b8d9b5 35
Eduvance 1:c94105b8d9b5 36 }
Eduvance 1:c94105b8d9b5 37
Eduvance 0:bd8fd0afc24a 38 }
Eduvance 1:c94105b8d9b5 39
Eduvance 1:c94105b8d9b5 40
Eduvance 1:c94105b8d9b5 41 void show(int m)
Eduvance 1:c94105b8d9b5 42 {
Eduvance 1:c94105b8d9b5 43 switch(m)
Eduvance 1:c94105b8d9b5 44 {
Eduvance 1:c94105b8d9b5 45 case 0:
Eduvance 1:c94105b8d9b5 46 Disp = 0xC0;
Eduvance 1:c94105b8d9b5 47 wait(0.005);
Eduvance 1:c94105b8d9b5 48 break;
Eduvance 1:c94105b8d9b5 49 case 1:
Eduvance 1:c94105b8d9b5 50 Disp = 0xF9;
Eduvance 1:c94105b8d9b5 51 wait(0.005);
Eduvance 1:c94105b8d9b5 52 break;
Eduvance 1:c94105b8d9b5 53 case 2:
Eduvance 1:c94105b8d9b5 54 Disp = 0xA4;
Eduvance 1:c94105b8d9b5 55 wait(0.005);
Eduvance 1:c94105b8d9b5 56 break;
Eduvance 1:c94105b8d9b5 57 case 3:
Eduvance 1:c94105b8d9b5 58 Disp = 0xB0;
Eduvance 1:c94105b8d9b5 59 wait(0.005);
Eduvance 1:c94105b8d9b5 60 break;
Eduvance 1:c94105b8d9b5 61 case 4:
Eduvance 1:c94105b8d9b5 62 Disp = 0x99;
Eduvance 1:c94105b8d9b5 63 wait(0.005);
Eduvance 1:c94105b8d9b5 64 break;
Eduvance 1:c94105b8d9b5 65 case 5:
Eduvance 1:c94105b8d9b5 66 Disp = 0x92;
Eduvance 1:c94105b8d9b5 67 wait(0.005);
Eduvance 1:c94105b8d9b5 68 break;
Eduvance 1:c94105b8d9b5 69 case 6:
Eduvance 1:c94105b8d9b5 70 Disp = 0x82;
Eduvance 1:c94105b8d9b5 71 wait(0.005);
Eduvance 1:c94105b8d9b5 72 break;
Eduvance 1:c94105b8d9b5 73 case 7:
Eduvance 1:c94105b8d9b5 74 Disp = 0xF8;
Eduvance 1:c94105b8d9b5 75 wait(0.005);
Eduvance 1:c94105b8d9b5 76 break;
Eduvance 1:c94105b8d9b5 77 case 8:
Eduvance 1:c94105b8d9b5 78 Disp = 0x80;
Eduvance 1:c94105b8d9b5 79 wait(0.005);
Eduvance 1:c94105b8d9b5 80 break;
Eduvance 1:c94105b8d9b5 81 case 9:
Eduvance 1:c94105b8d9b5 82 Disp = 0x90;
Eduvance 1:c94105b8d9b5 83 wait(0.005);
Eduvance 1:c94105b8d9b5 84 break;
Eduvance 1:c94105b8d9b5 85 default:
Eduvance 1:c94105b8d9b5 86 Disp = 0x04;
Eduvance 1:c94105b8d9b5 87 wait(0.005);
Eduvance 1:c94105b8d9b5 88 break;} }