本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uint count=0,freq=0;
uchar flag,times,scan;
uchar code dula[]={
0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90};
uchar disp[4]={
0xc0,0xc0,0xc0,0xc0};
void delay(uint z);
void display();
void init();
void main()
{
init();
while(1)
{
display();
}
}
void init()
{
P0=0xff;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
EX0=1;
TR0=1;
IT0=1;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void int0() interrupt 0
{
count++;
}
void t0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
times++;
if(times==20)
{
times=0;
EX0=0;
flag=1;
freq=count;
disp[3]=dula[freq/1000];
disp[2]=dula[freq%1000/100];
disp[1]=dula[freq%100/10];
disp[0]=dula[freq%10];
}
}
void display()
{
char i;
if(flag==1)
{
scan=0x01;
for(i=0;i<4;i++)
{
P0=0xff;
P2=~scan;
P0=disp;
delay(4);
scan<<=1;
}
}
} |