//= = declared area = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
# include & ltreg 5 1 . h & gt; //defines the header file of 805 1 register, P2- 17~ 19.
#define SEG P0 // Define seven-segment LED digital tube connected to port 0.
/* Declare seven-segment LED digital tube driving signal array (* * * Yang) */
Charcode tab [10] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99,//Numbers 0-4.
0x92,0x83,0xf8,0x80,0x 98 }; //Numbers 5-9
Invalid delay (int); //Declare the delay function
//= = Main program = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Main() // main program starts.
{unsigned character i; //Declare the unsigned variable i.
While (1) // loops indefinitely, and the program keeps running.
for(I = 0; I< 10; I++) // displays 0-9, *** 10 times.
{ SEG = TAB[I]; //Display numbers
Delay (500); //Delay 500× 1m=0.5 seconds
}//End of the for loop
}//End of main program
//= = Subroutine = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
/* delay function, the delay is about x× 1ms */
Void delay (int x) // Delay function start
{ int i,j; //declare integer variables I, J.
for(I = 0; I & ltx;; I++) // Count x times with a delay of x ×1ms.
for(j = 0; j & lt 160; j++); //Count 120 times, delay1ms.
}//End of delay function