用模拟单片机AT89C51做一个秒表,要程序,电路图,急,大神帮帮忙。
可以发文件,2971991775@qq.com,
软件是ISIS7画电路,KeiluVision4写程序
要求显示0-99,间隔1s,
有开始 暂停 复位开关
#include<reg51.h>
#define uchar unsigned char
uchar code ledtab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};//0-9
unsigned char sec=0,scanled;
unsigned char key,mode,time;
unsigned char disdat[2];
sbit keyqd=P1^0;
sbit keyzt=P1^1;
sbit keyql=P1^2;
void dischg()
{
disdat[0]=sec%10;
disdat[1]=sec/10;
}
void t0isr() interrupt 1 //秒计时
{
TH0=0x3c;
TL0=0xb0;
time++;
if(time==20)
{
time=0;
if(sec<99)sec++;
}
dischg();
}
void t1isr() interrupt 3 //显示
{
TH1=0xec;
TL1=0x78;
switch(scanled)
{
case 0:
P3=0x02;
P2=ledtab[disdat[1]];
break;
case 1:
P3=0x01;
P2=ledtab[disdat[0]];
break;
default:break;
}
scanled++;
scanled%=2;
}
main()
{
TMOD=0x11;
TH0=0x3c;
TL0=0xb0;
TH1=0xec;
TL1=0x78;
TR1=1;
TR0=0;
ET0=1;
ET1=1;
EA=1;
scanled=0;
time=0;
mode=1;
dischg();
while(1)
{
if(keyqd==0)
{
while(keyqd==0);
TR0=1;
}
if(keyzt==0)
{
while(keyzt==0);
TR0=0;
}
if(keyql==0)
{
while(keyql==0);
sec=0;
}
dischg();
}
}
好的,我去试试,好用就采纳