篮球比赛计时器的51单片机proteus仿真
2020-02-10 来源:51hei
51单片机仿真计时器的原理图:
部分源程序预览:
#include'main.h'
#include'delay.h'
#include'keypad.h'
#include'display.h'
void main()
{
INT0_Initial();
Time0_Initial();
delay_ms(10);
LED = 0;
while(1)
{
switch(key_value)
{
case 12:
{
num1 ++;key_value = 0;
flag1 = 0;
if(num1>255)
{
num1 = 0;
}
break;
}
case 13:
{
num1 --;key_value = 0;
flag1 = 0;
if(num1>255)
{
num1 = 255;
}
break;
}
case 14:
{
num2 ++;key_value = 0;
flag1 = 0;
if(num2>255)
{
num2 = 0;
}
break;
}
case 15:
{
num2 --;key_value = 0;
flag1 = 0;
if(num2>255)
{
num2 = 255;
}
break;
}
case 1:
{
TR0 = 1;
key_value = 0;
break;
}
case 2:
{
num1 = 0;num2 = 0;
num = 4;
secs = 0;minutes = 12;
m_secs = 24;
key_value = 0;
TR0 = 1;
break;
}
case 3:
{
TR0 = 0;
key_value = 0;
break;
}
default:
{
break;
}
}
HEXTOBCD();
delay_us(10);
Display(table);
delay_us(10);
}
}