首页 篮球计分器代码

篮球计分器代码

举报
开通vip

篮球计分器代码#include""#include""#defineuintunsignedint#defineucharunsignedcharintkey;intnum;intminute;intsecond;intas;intbs;mg,msuchartemp1[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};uchartemp2[8];sbitled=P3^2;sbitminytes=P2^7;sbitminyteg=P2^6;sbitse...

篮球计分器代码
#include""#include""#defineuintunsignedint#defineucharunsignedcharintkey;intnum;intminute;intsecond;intas;intbs;mg,msuchartemp1[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;}}elsesecond=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;elsenum++;}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}
本文档为【篮球计分器代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: ¥12.0 已有0 人下载
最新资料
资料动态
专题动态
个人认证用户
面向未来
性格开朗,工作认真,教学上进,多次评为为优秀教师。
格式:doc
大小:22KB
软件:Word
页数:0
分类:高中其他
上传时间:2020-10-22
浏览量:289