#include <io.h>
#include <delay.h> 

void main(void)
{      
    unsigned char digitSelect = 0;
    unsigned char i = 0;
    unsigned int num = 1234;   
    unsigned char sevenSegDigit[4];
    unsigned char sevenSegNum[10] = {
        0xC0,0xF9,0xA4,0xB0,0x99,
        0x92,0x82,0xF8,0x80,0x90
    };        

    DDRC = 0xFF;
    DDRD = 0xFF;  
                          
    //  [1   , 2   , 3  , 4]
    // [0x99, 0xB0, 0xA4, 0xF9]
    for(i = 0; i < 4; i++)
    {
        sevenSegDigit[i] = sevenSegNum[num % 10];
        num /= 10;
    }          
                       
    while(1)
    {      
        PORTC = 0xFF;               
        PORTD = 1 << digitSelect;  
        PORTC = sevenSegDigit[digitSelect];
        digitSelect++;
        if(digitSelect >= 4)
        {                  
            digitSelect = 0;
        }       
        
    }
}
   