谁帮帮忙用proteus 设计电子秒表系统 ,用2位LED数码显示,显示时间为00~99秒,每秒自动加1,“开始按键” 求高手为下面的仿真图设计一个51单片机实现秒表的程序,要求:...

\u7528AT89C51\u8bbe\u8ba1\u4e00\u4e2a2\u4f4d\u7684LED\u6570\u7801\u663e\u793a\u4f5c\u4e3a\u201c\u79d2\u8868\u201d

\u53ef\u4ee5\u53d1\u7ed9\u6211\u56fe

\u6c47\u7f16\u8fd8\u662fC\uff1f
#include
#define uchar unsigned char
#define uint unsigned int
sbit KS=P1^1;
sbit KP=P1^2;
sbit KC=P1^3;
uchar ge,shi;
uchar code tab[ ]={0xC0,0xF9,0xA4,0xB0,0x99,
0x92,0x82,0xF8,0x80,0x90,};

void delay(uint ms)
{
uchar a;
while(ms--)
for(a=123;a>0;a--);
}
void display();
void t0intinit( )//\u5b9a\u65f6\u5668T0\u521d\u59cb\u5316
{
TMOD=0x01;
TH0=0x3c;//50ms\u5b9a\u65f6
TL0=0xb0;
EA=1;
ET0=1;
}
void T0INT() interrupt 1 //\u5b9a\u65f6\u5668T0\u4e2d\u65ad \u65b9\u5f0f1
{
uchar time;
TH0=0x3c;
TL0=0xb0;
time++;
if(time==20) //20X50ms=1s
{
time=0;
ge++;
}
}
void main()
{
t0intinit( );
while(1)
{
while(!KS)
{delay(10);
if(KS)
TR0=1;
}
while(!KP)
{
delay(10);
if(KP)
TR0=0;
}
while(!KC)
{
delay(10);
if(KC)
TR0=0;
shi=0;
ge=0;
}
P2=tab[ge];
P0=tab[shi];
if(ge==10)
{
ge=0;
shi++;
}
if(shi==10)
{
shi=0;
}
}
}

//12M晶振。2位共阳数码管,P0为段码,P2.2、P2.3位控

//2011 05 07   三个按键:开始 P2.0  暂停 P2.1  清零 P2.2

#include <reg51.h>

#define uchar unsigned char

sbit P20=P2^0;

sbit P21=P2^1;

sbit KS=P2^5;

sbit KP=P2^6;

sbit KC=P2^7;

int ge,shi;

uchar code tab[ ]={0xC0,0xF9,0xA4,0xB0,0x99,

            0x92,0x82,0xF8,0x80,0x90,};

 

void delay_ms(unsigned int ms)  //1ms延时

{

    uchar a;

    while(ms--)

for(a=123;a>0;a--);

}

void display(); 

void t0intinit( ) //定时器T0初始化

{

TMOD=0x01;

TH0=0x3c;//50ms定时

TL0=0xb0;

EA=1;

ET0=1;

}

void Timer0Interrupt(void) interrupt 1    //定时器T0中断 方式1

{

uchar time; 

TH0=0x3c;

TL0=0xb0;

time++;

if(time==20)             //20X50ms=1s

{

time=0;

ge++;

}

}

void main()

{

t0intinit( );

while(1)

{

display( );

while(!KS)

{ display( );

if(KS)

TR0=1;

}

while(!KP)

{

display();

if(KP)

TR0=0;

}

while(!KC)

{

display( );

if(KC)

TR0=0;

shi=0;

ge=0;

}

  if(ge==10)

{

ge=0;

shi++;

}

if(shi==9)

{

shi=0;

}  

}

void display( )

{

P20=1;

P0=tab[ge];

delay_ms(1);

P20=0;

P21=1;

P0=tab[shi];

delay_ms(1);

P21=0;

}



这个...................

扩展阅读:proteus元器件查找大全 ... proteus元库下载导入 ... proteus免费下载 ... proteus不连线标点 ... proteus 8 professional ... proteus boy ... proteus黑色实心圆圆 ... proteus变压器变比怎么设 ... proteus元器件表图标大全 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网