标题: 篮球比赛计分器,仿真有点问题,大神来帮看看 [打印本页]

作者: ayumi_tt    时间: 2014-12-28 20:48
标题: 篮球比赛计分器,仿真有点问题,大神来帮看看
本帖最后由 ayumi_tt 于 2014-12-28 20:59 编辑

主要功能:
1.12分钟倒计时   
2.分别给A、B队加1、2、3分并显示
3.换场A、B两队分数交换
4.暂停

程序
#include<reg51.h>
unsigned char code seg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x00,0x90 };
int i=11,j=59,a=0,b=0,m=0,n=0,temp,s=0,r=24,k;
sbit aa=P0^0;
sbit bb=P0^1;
sbit one=P0^2;
sbit two=P0^3;
sbit three=P0^4;
sbit exchange=P0^5;
sbit stop=P0^6;
sbit led=P3^6;
sbit tt=P3^7;   
void delay(int x)
{  
int w,q;  
for(w=0;w<x;w++)
  for(q=0;q<120;q++);
}
void display(int i,int j,int a,int b)
{
P2 = 0x01;
P1 = seg[i/10];
delay(1);
P2 = 0x00;  
P2 = 0x02;
P1 = seg[i%10];
delay(1);
P2 = 0x00;   
P2 = 0x04;
P1 = seg[j/10];
delay(1);
P2 = 0x00;   
P2 = 0x08;
P1 = seg[j%10];
delay(1);   
P2 = 0x00;   
P2= 0x10;
P1 = seg[a/10];
delay(1);
P2= 0x00;   
P2= 0x20;  
P1 = seg[a%10];
delay(1);
P2 = 0x00;   
P2 = 0x40;
P1 = seg[b/10];
delay(1);
P2 = 0x00;   
  P2= 0x80;
  P1 = seg[b%10];
delay(1);
P2 = 0x00;  
}  
void time0() interrupt 1
{  
    TH0 = 0xb1;
  TL0 = 0xe0;
  m++;
if(m==50)
{
    m=0;
  j--;  
if(j==-1)   
j = 59;   
n++;  
if(n==60)
  {   
n=0;  
  i--;  
  if(i==0&&j==0){
    ET0=1;
    TR0 = 1;
   }
  }
}
display(i,j,a,b);
}   
void main()
{
P0 = 0x00;
display(12,0,0,0);
TMOD = 0x01;
  TH0 = 0xb1;
  TL0 = 0xe0;
  IE = 0x82;
TR0 = 1;
  while(1)
  {
  if(aa==1&&one==1)
    {a++;display( i, j, a, b);while(one==1);}
   else if(aa==1&&two==1)
    { a=a+2;display( i, j, a, b);while(two==1);}
     else if(aa==1&&three==1)
      {a=a+3;display( i, j, a, b);while(three==1);}
     else if(bb==1&&one==1)
      {b++;display( i, j, a, b);while(one==1);}
      else if(bb==1&&two==1)  
      { b=b+2;display( i, j, a, b);while(two==1);}
        else if(bb==1&&three==1)  
       { b=b+3;display( i, j, a, b);while(three==1);}
          else if(exchange==1)   
      {temp = a;a = b;b = temp;delay(500);}
         else if(stop==1)   
{ET0=0;TR0=0;while(stop==1);while(stop==0);while(stop==1){ET0=1;TR0=1;}}
  }
}
D:\
请问下比分那两块要怎么连线啊

QQ图片20141228204359.png (7.18 KB, 下载次数: 104)

QQ图片20141228204359.png

作者: ayumi_tt    时间: 2014-12-28 20:58
本帖最后由 ayumi_tt 于 2014-12-28 21:00 编辑

  不要沉呐
作者: admin    时间: 2015-4-20 17:18
这里有篮球单片机仿真:http://www.51hei.com/bbs/dpj-33685-1.html
作者: li975244245    时间: 2015-4-20 18:14
慢慢来
作者: 小雨456    时间: 2015-4-20 19:18
同求啊。。。。。。。。。。。。。。。。。。。。。。。
作者: 小雨456    时间: 2015-4-20 19:18
大神赶紧、、、、、、、、、、、、、、、、、、、、、、、、




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1