用
单片机进行0到59秒动态扫描显示,
仿真老是不对啊,程序改了很多次,基本上还是有问题,憋的慌
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit dl=P2^6;
sbit wl=P2^7;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar count,sec,min;
void delay(uint);
void main()
{
TMOD=0x01;
TL0=0x4c;
TH0=0x00;
EA=1;
ET0=1;
TR0=1;
P0=table[sec];
dl=1;
dl=0;
P0=0xfe;
wl=1;
wl=0;
delay(10);
P0=table[min];
dl=1;
dl=0;
P0=0xfd;
wl=1;
wl=0;
delay(10);
if(count==20)
{
count=0;
sec++;
}
if(sec==60)
{
sec=0;
min++;
}
if(min==60)
{
min=0;
}
}
/********************************/
void delay(uint i)
{
uint j;
for(;i>0;i--)
for(j=100;j>0;j--);
}
/********************************************/
void
time0()interrupt 1
{
TL0=0x4c;
TH0=0x00;
count++;
}
-
一周热门 更多>