篮球计分器代码.docx

上传人:b****8 文档编号:9470417 上传时间:2023-05-19 格式:DOCX 页数:9 大小:14.87KB
下载 相关 举报
篮球计分器代码.docx_第1页
第1页 / 共9页
篮球计分器代码.docx_第2页
第2页 / 共9页
篮球计分器代码.docx_第3页
第3页 / 共9页
篮球计分器代码.docx_第4页
第4页 / 共9页
篮球计分器代码.docx_第5页
第5页 / 共9页
篮球计分器代码.docx_第6页
第6页 / 共9页
篮球计分器代码.docx_第7页
第7页 / 共9页
篮球计分器代码.docx_第8页
第8页 / 共9页
篮球计分器代码.docx_第9页
第9页 / 共9页
亲,该文档总共9页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

篮球计分器代码.docx

《篮球计分器代码.docx》由会员分享,可在线阅读,更多相关《篮球计分器代码.docx(9页珍藏版)》请在冰点文库上搜索。

篮球计分器代码.docx

篮球计分器代码

#include""

#include""

#defineuintunsignedint

#defineucharunsignedchar

intkey;

intnum;

intminute;

intsecond;

intas;

intbs;

mg,ms

uchartemp1[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};

uchartemp2[8];

sbitled=P3^2;

sbitminytes=P2^7;

sbitminyteg=P2^6;

sbitseconds=P2^5;

sbitsecondg=P2^4;

sbita_s=P2^3;

sbita_g=P2^2;

sbitb_s=P2^1;

sbitb_g=P2^0;

voidkscan();

voiddelayms(uintz)//1ms延时

{

uintx,y;

for(x=z;x>0;x--)

for(y=110;y>0;y--);

}

voidshow()

{

inti,x;

for(i=0;i<8;i++)

{

P2=temp1[i];

x=temp2[i];

P0=temp[x];

delayms(5);

P0=0xff;

P2=0xff;

}

}

voidtime_s()

{

if(second==0)

{

if(minute==0)

b=0;

else

{

minute=minute-1;

second=59;

}

}

else

second=second-1;

}

voidcopy()

{

temp2[7]=minute/10;

temp2[6]=minute%10;

temp2[5]=second/10;

temp2[4]=second%10;

temp2[3]=as/10;

temp2[2]=as%10;

temp2[1]=bs/10;

temp2[0]=bs%10;

}

voidtime()

{

TMOD=0x01;

TH0=(65535-50000)/256;

TL0=(65535-50000)%256;

EA=0;

ET0=1;

TR0=1;

}

////////////////////////////////////////////

voidmain()

{

bs=0;

as=0;

minute=10;

second=0;

num=0;

time();

b=1;

led=0;

while

(1)

{

if(b==0)

{EA=0;led=1;}

if(num==20)

time_s();

copy();

show();

kscan();

}

}

////////////////////////////

voidT0_time()interrupt1

{

TH0=(65535-50000)/256;

TL0=(65535-50000)%256;

if(num==20)

num=0;

else

num++;

}

voidkscan()

{

inttemp,a;

P1=0xfe;

temp=P1;

temp=temp&0xf0;

if(temp!

=0xf0)

{

delayms(8);

if(temp!

=0xf0)

{

switch(temp)

{

case0xe0:

as=as+1;

break;

case0xd0:

as=as+2;

break;

case0xb0:

as=as+3;

break;

case0x70:

as=as-1;

break;

}

while(temp!

=0xf0)//松手检测

{

temp=P1;

temp=temp&0xf0;

}

}

}

P1=0xfd;

temp=P1;

temp=temp&0xf0;

if(temp!

=0xf0)

{

delayms(8);

if(temp!

=0xf0)

{

switch(temp)

{

case0xe0:

bs=bs+1;

break;

case0xd0:

bs=bs+2;

break;

case0xb0:

bs=bs+3;

break;

case0x70:

bs=bs-1;

break;

}

while(temp!

=0xf0)

{

temp=P1;

temp=temp&0xf0;

}

}

}

P1=0xfb;

temp=P1;

temp=temp&0xf0;

if(temp!

=0xf0)

{

delayms(8);

if(temp!

=0xf0)

{

switch(temp)

{

case0xe0:

as=0;bs=0;

break;

case0xd0:

a=as;as=bs;bs=a;

break;

case0xb0:

EA=0;

break;

case0x70:

minute=10;second=0;

break;

}

while(temp!

=0xf0)

{

temp=P3;

temp=temp&0xf0;

}

}

}

P1=0xf7;

temp=P1;

temp=temp&0xf0;

if(temp!

=0xf0)

{

delayms(8);

if(temp!

=0xf0)

{

switch(temp)

{

case0xe0:

EA=1;

break;

case0xd0:

if(second==59){second=0;minute=minute+1;}

elsesecond=second+1;

break;

case0xb0:

if(second==0)

{if(minute==0);

else

{minute=minute-1;second=59;}}

elsesecond=second-1;

break;

case0x70:

key=16;

break;

}

while(temp!

=0xf0)

{

temp=P1;

temp=temp&0xf0;

}

}

}

//返回值是num

}

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2