#include
#define uchar unsigned char //byte
#define uint unsigned int //word
sbit led1=P0^0;
sbit led2=P0^1;
sbit fir=P2^4; //fir=0;作业
sbit sec=P2^5; //sec=0;作业
sbit thi=P2^6; //thi=0;作业
sbit fot=P2^7; //fot=0;作业
uchar table[]={0x28,0xeb,0x32,0xa2,0xe1,0xa4,0x24,0xea,0x20,0xa0};
//P1=table[i]; 0 1 2 3 4 5 6 7 8 9
/**************************************************/
/* 延时模块 声明:void delay(int); */
/**************************************************/
void delay(int x) //如 delay(1000),延时1s
{
int i,j;
for(i=0;i
}
void main(void)
{/*初始化数据*/
uchar a;
a=0x08;
/*串口初始化,波特率为9600*/
TMOD=0x20;
PCON=0x00;
SCON=0x50;
TL1=0xfd;
TH1=0xfd;
TR1=1;
while(1)
{/*点亮4个数码管,P2为挑选数码管编号,P1为挑选数字,一起点亮led灯*/
delay(800);P2=0x0F;P1=table[0];led1=0; led2=1;
delay(800);P2=0x0F;P1=table[1];led1=1; led2=0;
delay(800);P2=0x0F;P1=table[2];led1=0; led2=1;
delay(800);P2=0x0F;P1=table[3];led1=1; led2=0;
delay(800);P2=0x0F;P1=table[4];led1=0; led2=1;
delay(800);P2=0x0F;P1=table[5];led1=1; led2=0;
delay(800);P2=0x0F;P1=table[6];led1=0; led2=1;
delay(800);P2=0x0F;P1=table[7];led1=1; led2=0;
delay(800);P2=0x0F;P1=table[8];led1=0; led2=1;
delay(800);P2=0x0F;P1=table[9];led1=1; led2=0;
/*发送字节数据*/
SBUF=a;
while(TI==0) ;
TI=0;
}
}