It makes two seven segments count from 0 to 99

Dependencies:   mbed

Committer:
EduRemo
Date:
Fri Feb 05 07:05:30 2016 +0000
Revision:
0:fb420818dd95
At FRCRCE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
EduRemo 0:fb420818dd95 1 #include "mbed.h"
EduRemo 0:fb420818dd95 2
EduRemo 0:fb420818dd95 3 BusOut Disp(PTC9, PTC8, PTA5,PTA4, PTA12,PTD4,PTA2,PTA1); // ABCDEFGdp
EduRemo 0:fb420818dd95 4 DigitalOut vdd1(PTA13); // (for selecting Ten's digit give vcc here)
EduRemo 0:fb420818dd95 5 DigitalOut vdd2(PTD5); // (for selecting One's digit give vcc here)
EduRemo 0:fb420818dd95 6
EduRemo 0:fb420818dd95 7 void show_number(int m);
EduRemo 0:fb420818dd95 8
EduRemo 0:fb420818dd95 9 void set_Tens_Digit()
EduRemo 0:fb420818dd95 10 {vdd1 = 1;
EduRemo 0:fb420818dd95 11 vdd2 =0;}
EduRemo 0:fb420818dd95 12
EduRemo 0:fb420818dd95 13 void set_Ones_Digit()
EduRemo 0:fb420818dd95 14 {vdd1 = 0;
EduRemo 0:fb420818dd95 15 vdd2 = 1;}
EduRemo 0:fb420818dd95 16
EduRemo 0:fb420818dd95 17 int i = 0;
EduRemo 0:fb420818dd95 18 int j = 0;
EduRemo 0:fb420818dd95 19 int k = 0;
EduRemo 0:fb420818dd95 20 int m = 0;
EduRemo 0:fb420818dd95 21 int n = 0;
EduRemo 0:fb420818dd95 22
EduRemo 0:fb420818dd95 23 int main() {
EduRemo 0:fb420818dd95 24 while(1){
EduRemo 0:fb420818dd95 25 for (i=0; i<=99; i++){
EduRemo 0:fb420818dd95 26 j = i / 10;
EduRemo 0:fb420818dd95 27 k = i % 10;
EduRemo 0:fb420818dd95 28 for(n=0; n<99; n++){
EduRemo 0:fb420818dd95 29 set_Tens_Digit();
EduRemo 0:fb420818dd95 30 show_number(j);
EduRemo 0:fb420818dd95 31 set_Ones_Digit();
EduRemo 0:fb420818dd95 32 show_number(k);}
EduRemo 0:fb420818dd95 33 }
EduRemo 0:fb420818dd95 34 }
EduRemo 0:fb420818dd95 35 }
EduRemo 0:fb420818dd95 36
EduRemo 0:fb420818dd95 37
EduRemo 0:fb420818dd95 38 void show_number(int m)
EduRemo 0:fb420818dd95 39 {
EduRemo 0:fb420818dd95 40 switch(m)
EduRemo 0:fb420818dd95 41 {
EduRemo 0:fb420818dd95 42 case 0:
EduRemo 0:fb420818dd95 43 Disp = 0xC0;
EduRemo 0:fb420818dd95 44 wait(0.005);
EduRemo 0:fb420818dd95 45 break;
EduRemo 0:fb420818dd95 46 case 1:
EduRemo 0:fb420818dd95 47 Disp = 0xF9;
EduRemo 0:fb420818dd95 48 wait(0.005);
EduRemo 0:fb420818dd95 49 break;
EduRemo 0:fb420818dd95 50 case 2:
EduRemo 0:fb420818dd95 51 Disp = 0xA4;
EduRemo 0:fb420818dd95 52 wait(0.005);
EduRemo 0:fb420818dd95 53 break;
EduRemo 0:fb420818dd95 54 case 3:
EduRemo 0:fb420818dd95 55 Disp = 0xB0;
EduRemo 0:fb420818dd95 56 wait(0.005);
EduRemo 0:fb420818dd95 57 break;
EduRemo 0:fb420818dd95 58 case 4:
EduRemo 0:fb420818dd95 59 Disp = 0x99;
EduRemo 0:fb420818dd95 60 wait(0.005);
EduRemo 0:fb420818dd95 61 break;
EduRemo 0:fb420818dd95 62 case 5:
EduRemo 0:fb420818dd95 63 Disp = 0x92;
EduRemo 0:fb420818dd95 64 wait(0.005);
EduRemo 0:fb420818dd95 65 break;
EduRemo 0:fb420818dd95 66 case 6:
EduRemo 0:fb420818dd95 67 Disp = 0x82;
EduRemo 0:fb420818dd95 68 wait(0.005);
EduRemo 0:fb420818dd95 69 break;
EduRemo 0:fb420818dd95 70 case 7:
EduRemo 0:fb420818dd95 71 Disp = 0xF8;
EduRemo 0:fb420818dd95 72 wait(0.005);
EduRemo 0:fb420818dd95 73 break;
EduRemo 0:fb420818dd95 74 case 8:
EduRemo 0:fb420818dd95 75 Disp = 0x80;
EduRemo 0:fb420818dd95 76 wait(0.005);
EduRemo 0:fb420818dd95 77 break;
EduRemo 0:fb420818dd95 78 case 9:
EduRemo 0:fb420818dd95 79 Disp = 0x90;
EduRemo 0:fb420818dd95 80 wait(0.005);
EduRemo 0:fb420818dd95 81 break;
EduRemo 0:fb420818dd95 82 default:
EduRemo 0:fb420818dd95 83 Disp = 0x04;
EduRemo 0:fb420818dd95 84 wait(0.005);
EduRemo 0:fb420818dd95 85 break;} }