标题:
AT89C51 60s倒计时
[打印本页]
作者:
SUPERCHIGGA
时间:
2018-4-26 11:12
标题:
AT89C51 60s倒计时
#include <at89x51.h>
#define uchar unsigned char
uchar display[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void yan10ms();
void main()
{
uchar i,n;
for(i=24;i>0;i--)
{
for(n=50;n>0;n--)
{
if(i/10==0)
{P0=0xff;}
else
{P2_1=0;P2_0=1;P0=display[i/10];}
yan10ms();
P2_0=0;P2_1=1;P0=display[i%10];yan10ms();
}
P3_0=0;yan10ms();P3_0=1;
}
P2_0=0;P2_1=1;P0=display[0];P3_0=0; while(1);
}
void yan10ms() //10ms
{
uchar i,j;
for(j=20;j>0;j--)
{for(i=250;i>0;i--);}
}
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1