缘由接通电源0~2秒内 LED点阵显示状态为 全亮2~3秒 显示【P】3~4秒 显示【I】4~5-其他-CSDN问答
- #include
//头文件 -
- unsigned char code shuju[][8]={{0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff},{0x00,0x00,0x7F,0x48,0x48,0x30,0x00,0x00},
- {0x00,0x82,0x82,0xFE,0x82,0x82,0x00,0x00},{0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00},
- {0x18,0x24,0x12,0x12,0x12,0x24,0x18,0x00}, {0x00,0x7C,0x02,0x02,0x02,0x7C,0x00,0x00}};//数据
- unsigned char code sjwei[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//位
- unsigned char Js=0;//中断计时
- unsigned char Mo=0;//秒
- bit k=0;
- void ZhongDuanSheZhi()
- {
- TH0+=0X4c;/*定时器赋初值,定时50ms触发中断,自动补偿方式*/
- TL0+=0X00;
- TMOD=0X01;
- TR0=ET0=EA=1; //开启定时器开启全局中断开关
- }
- void JiShi(/*时间计算*/)
- {
- if(Js>=20)
- {
- Js=0;
- if(Mo>=2)k=1;
- if(++Mo>7)Mo=0;
- }
- }
- void main()
- {
- unsigned char b=0, j=0, xd=0;
- ZhongDuanSheZhi();
- while(1)
- {
- P2=shuju[j][b];
- P3=sjwei[b];
- while(++xd)JiShi();//显示延时
- P3=255;//换位消隐
- if(++b>7)b=0;
- if(k){k=0;if(++j>=6)j=0;}
- }
- }
- void ZhongDuan() interrupt 1
- {
- ++Js;
- TH0+=0X4c;
- TL0+=0X00;
- }