51单片机电子时钟proteus仿真,要求有程序还有proteus仿真
能加QQ吗,我有问题要问你,现在要做课程设计了,谢谢!!!我的QQ:2505871356麻烦加我...
能加QQ吗,我有问题要问你,现在要做课程设计了,谢谢!!!我的QQ:2505871356麻烦加我
展开
展开全部
/*************************************************************
功能:
实现电子时钟显示(C)
定义:
P2口位选,P0口段选
时间:
2010—11—26
*************************************************************/
#include<reg52.h>
code unsigned char tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char StrTab[6];
unsigned char minute=30,hour=12,second=0;
void Displaypro(void)
{
StrTab[0]=tab[second%10];
StrTab[1]=tab[second/10];
StrTab[2]=tab[minute%10];
StrTab[3]=tab[minute/10];
StrTab[4]=tab[hour%10];
StrTab[5]=tab[hour/10];
}
main()
{
TMOD |=0x01;
TH0=0xd8;
TL0=0xf0;
ET0=1;
TR0=1;
TMOD |=0x10;
TH1=0xF8;
TL1=0xf0;
ET1=1;
TR1=1;
EA =1;
while(1){;}
}
void time1_isr(void) interrupt 3
{
static unsigned char num;
TH1=0xf8;
TL1=0xf0;
switch (num)
{
case 0:P2=0x01;P0=StrTab[num];break;
case 1:P2=0x02;P0=StrTab[num];break;
case 2:P2=0x04;P0=StrTab[num];break;
case 3:P2=0x08;P0=StrTab[num];break;
case 4:P2=0x10;P0=StrTab[num];break;
case 5:P2=0x20;P0=StrTab[num];break;
default:break;
}
num++;
if(num==6)
num=0;
}
void tim(void) interrupt 1
{
static unsigned char count;
TH0=0xd8;
TL0=0xf0;
count++;
switch (count)
{
case 0:
case 20:
case 40:
case 60:
case 80:Displaypro();break;
default:break;
}
if (count==100)
{
count=0;
second++;
if(second==60)
{
second=0;
minute++;
if(minute==60)
{
minute=0;
hour++;
if(hour==24)
hour=0;
}
}
}
}
功能:
实现电子时钟显示(C)
定义:
P2口位选,P0口段选
时间:
2010—11—26
*************************************************************/
#include<reg52.h>
code unsigned char tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char StrTab[6];
unsigned char minute=30,hour=12,second=0;
void Displaypro(void)
{
StrTab[0]=tab[second%10];
StrTab[1]=tab[second/10];
StrTab[2]=tab[minute%10];
StrTab[3]=tab[minute/10];
StrTab[4]=tab[hour%10];
StrTab[5]=tab[hour/10];
}
main()
{
TMOD |=0x01;
TH0=0xd8;
TL0=0xf0;
ET0=1;
TR0=1;
TMOD |=0x10;
TH1=0xF8;
TL1=0xf0;
ET1=1;
TR1=1;
EA =1;
while(1){;}
}
void time1_isr(void) interrupt 3
{
static unsigned char num;
TH1=0xf8;
TL1=0xf0;
switch (num)
{
case 0:P2=0x01;P0=StrTab[num];break;
case 1:P2=0x02;P0=StrTab[num];break;
case 2:P2=0x04;P0=StrTab[num];break;
case 3:P2=0x08;P0=StrTab[num];break;
case 4:P2=0x10;P0=StrTab[num];break;
case 5:P2=0x20;P0=StrTab[num];break;
default:break;
}
num++;
if(num==6)
num=0;
}
void tim(void) interrupt 1
{
static unsigned char count;
TH0=0xd8;
TL0=0xf0;
count++;
switch (count)
{
case 0:
case 20:
case 40:
case 60:
case 80:Displaypro();break;
default:break;
}
if (count==100)
{
count=0;
second++;
if(second==60)
{
second=0;
minute++;
if(minute==60)
{
minute=0;
hour++;
if(hour==24)
hour=0;
}
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询