It makes two seven segments count from 0 to 99

Dependencies:   mbed

main.cpp

Committer:
EduRemo
Date:
2016-02-05
Revision:
0:fb420818dd95

File content as of revision 0:fb420818dd95:

#include "mbed.h"

BusOut Disp(PTC9, PTC8, PTA5,PTA4, PTA12,PTD4,PTA2,PTA1); // ABCDEFGdp
DigitalOut vdd1(PTA13); // (for selecting Ten's digit give vcc here)
DigitalOut vdd2(PTD5); // (for selecting One's digit give vcc here)

void show_number(int m);

void set_Tens_Digit()
{vdd1 = 1;
vdd2 =0;}

void set_Ones_Digit()
{vdd1 = 0;
vdd2 = 1;}

int i = 0;
int j = 0;
int k = 0;
int m = 0;
int n = 0;

int main() {
    while(1){
        for (i=0; i<=99; i++){
            j = i / 10;
            k = i % 10;
        for(n=0; n<99; n++){
            set_Tens_Digit();
            show_number(j);
            set_Ones_Digit();
            show_number(k);}
            }
        }
}


void show_number(int m)
{
    switch(m)
    {
     case 0:
       Disp = 0xC0; 
       wait(0.005);  
       break;
    case 1:
       Disp = 0xF9; 
       wait(0.005); 
       break;
    case 2:
       Disp = 0xA4; 
       wait(0.005);  
       break; 
    case 3:
       Disp = 0xB0; 
       wait(0.005);  
       break;
    case 4:
       Disp = 0x99; 
       wait(0.005);  
       break;
    case 5:
       Disp = 0x92; 
       wait(0.005);  
       break;
    case 6:
       Disp = 0x82; 
       wait(0.005);  
       break;
    case 7:
       Disp = 0xF8; 
       wait(0.005);  
       break;
    case 8:
       Disp = 0x80; 
       wait(0.005);  
       break;
    case 9:
       Disp = 0x90; 
       wait(0.005);  
       break;
    default:
        Disp = 0x04; 
       wait(0.005);  
       break;}    }