Counts 00-99 on Multiplexed Seven Segment Diaplay

Dependencies:   mbed

main.cpp

Committer:
Eduvance
Date:
2014-05-27
Revision:
1:c94105b8d9b5
Parent:
0:bd8fd0afc24a
Child:
2:00ae261aa180

File content as of revision 1:c94105b8d9b5:

#include "mbed.h"

BusOut Disp(p26,p25,p24,p23,p22,p21,p20); // ABCDEFGdp
DigitalOut vdd1(p19); 
DigitalOut vdd2(p18);

void show(int m);

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

void setvdd2()
{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++){
            setvdd2();
            show(j);
            setvdd1();
            show(k);}
            }
        
        
        }
    
}


void show(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;}    }