#include?<reg51.h>
#include?<stdio.h>
#define?uchar?unsigned?char
void?convert();
void?display();
void?delay();
//***陰:0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
code?unsigned?char?Led[16]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,
0x77,0x7C,0x39,0x5E,0x79,0x71};
uchar?num,sw,gw;
void?main()
{
num=0; while(1) { convert(); display(); delay(); num++; if(num==100)num=0; }}
void?convert()
{
sw=num/10; gw=num%10;}
void?display()
{
P1=Led[gw]; P2=Led[sw];?}
void?delay()
{
uchar?i,j,k; for(k=0;k<2;k++) for(i=0;i<250;i++)for(j=0;j<250;j++);
}
使用仿真軟件電路連接如下圖