///////////////////////////////////////////////////////////////////////////////////////////////////
unsigned short i;
INTCON = 0; // Disable GIE , PEIE , INTE , RBIE , TOIE
TRISA = 0;
PORTA = 0;
TRISD = 0;
PORTD = 0;
while (1) {
for (i = 0; i <= 9u; i++)
{
PORTA = 0; // Turn off all 7seg displays
PORTD = mask(i); // bring appropriate value to PORTD
PORTA = 1; // turn on appropriate 7seg. display
Delay_ms (1000);
}
}
}
unsigned short mask( unsigned short num)
{
switch (num) {
case 0 : return 0x3F;
case 1 : return 0x06;
case 2 : return 0x5B;
case 3 : return 0x4F;
case 4 : return 0x66;
case 5 : return 0x6D;
case 6 : return 0x7D;
case 7 : return 0x07;
case 8 : return 0x7F;
case 9 : return 0x6F;
}}
Aucun commentaire:
Enregistrer un commentaire