本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
代码烧入后,数码管只有一位间隔的显示0
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit key=P3^5;
sbit dula=P2^6;
sbit wela=P2^7;
uchar num,count;
uchar code shu[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x00};
uchar shu_bit[]={
0x7f,0xbf,0xdf,0xef};
uchar bu_count[]={0,0,0};
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j++);
}
void show_count()
{
uchar i;
bu_count[2] =count/100;
bu_count[1] =count%100/10;
bu_count[0] =count%10;
for(i=2;i>0;i--)
{
dula=1;
P0=shu[bu_count[i]];
dula=0;
P0=0xff;
wela=1;
P0=shu_bit[i];
wela=0;
delayms(5);
}
}
void main()
{
num=0;
count=0;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TMOD=0x10;
EA=1;
ET1=1;
show_count();
while(1)
{
show_count();
while(key==0)
{
delayms(5);
while(key==0)
{
TR1=1;
while(!key);
}
}
}
}
void int1() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
num++;
if(num==20)
{
num=0;
count++;
}
} |