篮球比赛计时计分器程序_第1页
篮球比赛计时计分器程序_第2页
篮球比赛计时计分器程序_第3页
篮球比赛计时计分器程序_第4页
篮球比赛计时计分器程序_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、#iiiclude HReg51.hninclude Hmtiins.hH frdefine IO_DISDataBus PO 定义显示转数据总线sbit IO_Nixie 1 =P2ZO;/定义数码管位码输入I 1sbit IO_Nixie2=P2Al;sbit IO_Nixie3=P2A2;sbit IO_Nixie4=P2A3;sbit IO_Nixie5=P2A4;sbit IO_Nixie6=P2A5;sbit IO_Nixie7=P2A6;sbit IO_Nixie8=P2A7; TOC o 1-5 h z define NIXIE 10#define NIXIE21#define

2、 NIXIE32#define NIXIE43#define NIXIE54#define NIXIE65define NIXIE76#define NIXIE87 sbit IO_Beep=P3A0;sbit IO_LED=P3 沮;sbit IO_Keyl=PlA0; 定义按键输入I Isbit IO Kev2=PlAl;sbit IO Kev3=PlA2;sbit IO Kev4=PlA3;sbit IO Kev5=Plz4;sbit IO Kev6=PlA5;sbit IO Kev7=Plz6;sbit IO Kev8=PlA7;#define KEY 1 0#define KEY2

3、1#define KEY3 2#define KEY4 3#define KEY5 4#define KEY6 5#define KEY7 6#define KEY8 7unsigned char R_KeyFlag8.R_KeyDowiiFlag8,R_KeyCount8;/定义按键工作寄存器 unsigned char R_KeyPomt;unsigned char R_DisplayNUM8=0,0,0,0,0,0,0,0;定义8个数码管显示数据寄存器及数码管 使能寄存器unsigned char R_DisplayEnable8=0,0,0.0,0,0,0.0;unsigned cha

4、r R_DisplayPomt;unsigned char R_Dotl.R_Dot2;unsigned char R_DisplayCode10=0 xc0.0 x段0 xa4,0 xb0,0 x99,0 x92,0 x82,0 xd8,0 x80,0 x90;数 码管段码unsigned char R_SecondFlash,R_TuneFlashFlag;unsigned mt R_BeepCount;unsigned mt R_LEDCoimt;unsigned char R_TeamScore_LR_TeamScore_2;unsigned mt R_SecondCount;unsi

5、gned char R_SecondCountEN.R_SecondFlag;unsigned char R_SetMinute,R_SetSecond.R_Mmute.R_Second;unsigned char R_StaitGameFlag.R_StopGameFlag,R_SetTuneFlag;unsigned mt R_SetTiineCount;void Delay(unsigned mt number) 延时函数unsigned mt R_count_;fdi(R_count_=0;R_count_v=number;R_count_+)(_nop_();_nop_();_nop

6、_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();void GetKey(void)/获得按键函数R_KeyPomt+;iRR_KeyPoint7)R_KeyPomt=0;/-iRR_KeyP omt=0)if(IO_Keyl=0)(R_KeyCountR_KeyPoint+;if(R_KeyCountR_KeyPoint 1)(R_KeyCount R_KeyPoint=100;/-R_KeyDowiiFlag R_KeyPoint =Oxff;)else(R_KeyCountR_KeyPomt=0;if(R_KeyDow

7、iiFlagR_KeyPomt)(if(IO_Keyl)(R_KeyDowiiFlagR_KeyPomt=0 x00;/-R_KeyFlagR_KeyPomt=Oxff;)else if(R_KeyPoint= 1)R_KeyCountR_KeyPoint+;if(R_KeyCountR_KeyPoint 1)(R_KeyCountR_KeyPoint=l 00;/-R_KeyDowiiFlagR_KeyPomt=Oxff:)else(R_KeyCountR_KeyPoint=0;if(R_KeyDowiiFlagR_KeyPomt)(if(IO_Key2)(R_KeyDowiiFlagR_K

8、eyPomt=0 x00;/-R_KeyFlagR_KeyPomt=Oxff;)else if(R_KeyPoint=2)fRlO_Key3=0)(R_KeyCountR_KeyPoint+;if(R_KeyCountR_KeyPoint 1)(R_KeyCountR_KeyPoint=l 00;/-R_KeyDowiiFlagR_KeyPomt=Oxff:)else(R_KeyCountR_KeyPoint=0;if(R_KeyDowiiFlagR_KeyPomt)(if(IO_Key3)R_KeyDowiiFlagR_KeyPomt=0 x00;/-R_KeyFlagR_KeyPomt=O

9、xff;)else if(R_KeyPoint=3)氓IO_Key4=0)(R_KeyCountR_KeyPoint+;if(R_KeyCountR_KeyPoint 1)(R_KeyCountR_KeyPoint=l 00;/-R_KeyDowiiFlagR_KeyPomt=Oxff:)else(R_KeyCountR_KeyPoint=0;)if(R_KeyDowiiFlagR_KeyPomt)(if(IO_Key4)(R_KeyDowiiFlagR_KeyPomt=0 x00;/-R_KeyFlagR_KeyPomt=Oxff;)else if(R_KeyPoint=4)iRlO_Key

10、5=0)(R_KeyCountR_KeyPoint+;if(R_KeyCountR_KeyPoint 1)(R_KeyCountR_KeyPoint=l 00;/-R_KeyDowiiFlagR_KeyPomt=Oxff:)elseR_KeyCountR_KeyPoint=0;)if(R_KeyDowiiFlagR_KeyPomt)(if(IO_Key5)(R_KeyDowiiFlagR_KeyPomt=OxOO;/-R_KeyFlagR_KeyPomt=Oxff;)else if(R_KeyPoint=5)fRlO_Key6=0)(R_KeyCountR_KeyPoint+;if(R_Key

11、CountR_KeyPoint 1)(R_KeyCountR_KeyPoint=l 00;/-R_KeyDowiiFlagR_KeyPomt=Oxff:)else(R_KeyCountR_KeyPoint=0;)if(R_KeyDowiiFlagR_KeyPomt)(if(IO_Key6)(R_KeyDowiiFlagR_KeyPomt=0 x00;/-R_KeyFlagR_KeyPomt=Oxff;)else if(R_KeyPoint=6)fif(IO_Key7=0)R_KeyCountR_KeyPouit+; if(R_KeyCountR_KeyPoint 1)R_KeyCountR_K

12、eyPoint=l 00;/-R_KeyDowiiFlagR_KeyPomt=Oxff:)else(R_KeyCountR_KeyPoint=0;if(R_KeyDowiiFlagR_KeyPomt)(if(IO_Key7)(R_KeyDowiiFlagR_KeyPomt=0 x00;/-R_KeyFlagR_KeyPomt=Oxff;)else if(R_KeyPoint=7)if(IO_Key8=0)(R_KeyCountR_KeyPoint+;if(R_KeyCountR_KeyPoint 1)(R_KeyCountR_KeyPoint=l 00;/-R_KeyDowiiFlagR_Ke

13、yPomt=Oxff:)else(R_KeyCountR_KeyPoint=0;if(R_KeyDowiiFlagR_KeyPomt)(if(IO_Key8)(R_KeyDowiiFlagR_KeyPomt=0 x00;/-R_KeyFlagR_KeyPomt=Oxff;):T=taiXTMOI ”=9TXTNOI J冲Np :T = T9TXTKOI -7/ :0=】UTOd向 dSTOpa Qv)EOdAcdSTCTM)JT !+)UTOdAedsTcr ) 豚网器凝世曹/(PT。、)网dSTp pTOA 01 %Q)nuTjr=t7i/iwAi3dsTcr 0T/00 T %叫问11一=

14、Hir2dsTcr OT %puo“sr=CMQNX田dsTQF -0T/00 T %puo“sr=】也2【dsTcT-7/ :0 T % 乙0IOOSIUC0I=Ol,QNXe【dsTcr 01/00 T %o.tooshic9I-h= T WaNXeidsTQr-7/:0 T %0IOSIUC0I =9HIf2dsTcr 01/00 T %0ioSiuc0JLr=zJ WaNXeidsTQr) 却 世咎曲 q/(pTOA)U)UaSiaSS93OJd PTOA :00X0=3 叩耳 r :00X0=93 叩耳 r :ooxo=K3 叩耳 r :ooxo=03 叩耳 r :00X0=3 叩耳

15、 r :ooxo=3叩耳r :ooxo=t3 叩耳 r :ooxo=o3 叩耳 r) 豚网避舛款醇溷熟(PTOA)斑但辰/TUQQ PTOA (IO-Nixie5=l;IO-Nixie6=l;IO-Nixie7=l;IO-Nixie8=l;/Delay(50);/-if(R_DisplayPoint=0)if(R_DisplayEnableR_DisplayPomt)(IO_DISDataBus=R_DisplayCodeR_DisplayNUMR_DisplayPomt;else(IO_DISDataBus=Oxff;)IO_Nixiel=0;else iRR_DisplayPoint=l)

16、if(R_DisplayEnableR_DisplayPomt)(IO_DISDataBus=R_DisplayCodeR_DisplayNUMR_DisplayPoint;else(IO_DISDataBus=Oxff;)IO_Nixie2=0;else iRR_DisplayPoint=2)if(R_DisplayEnableR_DisplayPomt)(IO_DISDataBus=R_DisplayCodeR_DisplayNUMR_DisplayPoint-R_Dotl;else(IO DISDataBus=0 xff-R Doti;)IO_Nixie3=0;else iRR_Disp

17、layPoint=3)if(R_DisplayEnableR_DisplayPomt)(IO_DISDataBus=R_DisplayCodeR_DisplayNUMR_DisplayPoint-R_Dot2;else(IO DISDataBus=0 xff-R Dot2;)IO_Nixie4=0;else iRR_DisplayPoint=4)fif(R_DisplayEnableR_DisplayPomt)(IO_DISDataBus=R_DisplayCodeR_DisplayNUMR_DisplayPoint;else(IO_DISDataBus=Oxff;)IO_Nixie5=0;e

18、lse iRR_DisplayPoint=5)fif(R_DisplayEnableR_DisplayPomt)(IO_DISDataBus=R_DisplayCodeR_DisplayNUMR_DisplayPoint;else(IO_DISDataBus=Oxff;)IO_Nixie6=0;else iRR_DisplayPoint=6)fif(R_DisplayEnableR_DisplayPomt)(IO_DISDataBus=R_DisplayCodeR_DisplayNUMR_DisplayPoint;elseIO_DISDataBus=Oxff;IO_Nixie7=0;else

19、if(R_DisplayPomt=7)if(R_DisplayEnableR_DisplayPomt)(IO_DISDataBus=R_DisplayCodeR_DisplayNUMR_DisplayPoint;)else(IO_DISDataBus=Oxff;)IO_Nixie8=0;elsevoid TimeO(void) iiiternipt 1 using 1 /TO 中断入 I ITH0=0 xfc;TL0=0 x!7;/-采集按键-GetKeyO;/一显示一DisplayO;/计时if(R_SecondCountEN)if(R_StopGameFlag=OxOO)R_SecondC

20、ouiit+;if(R_SecondCount 1000)R_SecondC ount=0;/-R_SecondFlag=Oxff;) elseR_SecondCouiit=0;if(R_SecondFlash)if(R_SecondCount500)iR_Dotl=0;R_Dot2=0;)elseriR_Dotl=128;R_Dot2=128;elseR_Dotl=128;R_Dot2=128;/if(R_TmieFlashFlag)R_SetTimeCount+;if(R_SetTimeCount500)/iR_SetTmieC ount=0;)if(R_SetTimeCount 150)

21、iR_DisplayEnable 2 =0 xff;R_DisplayEnable 3 =0 xff;R_DisplayEnable4=0 xff;R_DisplayEnable5=0 xff;)elseR_DisplayEnable2=0 x00;R_DisplayEnable 3 =0 x00;R_DisplayEnable4=0 x00;R_DisplayEnable5=0 x00;elseR_DisplayEnable2=0 xff;R_DisplayEnable3=0 xff;R_DisplayEnable4=0 xff;R_DisplayEnable5=0 xff;/-if(R_B

22、eepCount)R_BeepCount-;/IO_Beep=0:elseIO_Beep=l;if(R_LEDCount)R_LEDCount;/IO_LED=0;elseIO_LED=1;/-void StartGame(void)/开始比赛R_StaitGameFlag=Oxff;/-while(R_StailGaiiieFlag)/-R_SecondCountEN=Oxff;R_StopGameFlag=Oxff:R_SecondFlash=OxOO;/-R Mmute=R SetMmute;R Second=R SetSecond;/-ClearKeyFlagQ;/-while(R_S

23、tartGameFlag)(/-按键处理if(R_KeyFlagKEY3)(R_KeyFlagKEY3=OxOO;/-R_BeepCount=50:if(R_MmuteR_SetMmute)| (R_Second99)(R TeainScore 1=99;)if(R_KeyFlagKEY2)/ 设置 1 队分数R_KeyFlagKEY2=0 x00;/-R_BeepCount=50;R TeainScoreif(R_TeaniScoie_l200) (R TeainScore 1=0;)if(R_KeyFlagKEY7)/设置 2 队分数 R_KeyFlagKEY7=0 x00;/-R_Bee

24、pC ount=5 0;R_TeainScoie_2+;iRR_TeamScore_299) (R TeainScore 2=99;)if(R_KeyFlagKEY8)/设置 2 队分数 R_KeyFlagKEY8=0 x00;/-R_BeepCount=50;R TeainScore 2;iRR_TeamScore_2200) (R TeainScore 2=0;)/-/-按键处理完毕-/-时间处理 if(R_SecondFlag) R_SecondFlag=0 x00;/- if(R_Second=0) (else(R_Second-;/if(R_Mmute=0)&(R_Second59)

25、(R_SetMinute=59;)if(R_KeyFlagKEY2)/ 设置分钟R_KeyFlagKEY2=0 x00;/-R_BeepCount=50:R_SetMiiiute-;if(R_SetMinute200)(R_SetMinute=O;)if(R.KeyFlagKEY7)/ 设置秒R_KeyFlagKEY7=OxOO;/-R_BeepCount=50:R_SetSecond+;if(R_SetSecond59)R_SetSecond=59;if(R_KeyFlagKEY8)/ 设置秒(R_KeyFlagKEY8=OxOO;/-R_BeepCount=50;R_SetSecond-;if(R_SetSecond200)(R_SetSecond=0;)/-if(R_KeyFlagKEY5)(R_KeyFlagKEY5=OxOO;/-R_BeepCount=500;R_SetT uneFlag=OxOO;)-按键处理完毕-_处理显示-_R Mmute=R SetMinute;R Second=R SetSecond;ProcessDISDataQ;/-处理显示完毕)R_TmieFlashFlag=OxOO;R_SecondFlash=OxOO;-ClearKeyFlagO;-) void main(void)/i 函

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论