Circuit:



Code:



#include <reg51.h>
sbit pushbutton=P0^0; 
void DELAY_ms(unsigned int ms_Count) {     
    unsigned int i,j;     
    for(i=0;i<ms_Count;i++)       
    for(j=0;j<100;j++); 
} 
void main()  {
    char seg_code[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};     
    int i=0;   
    pushbutton=1;   
    P2 = seg_code[i];     
    while (1)  {    
        if(pushbutton==1) {     
            i++;     
            if(i==10) {      
                i=0; 
            }          
            P2 = seg_code[i];     
            DELAY_ms(500);    
        }   
    } 
}