篮球计时计分器c语言程序,C51的篮球计时计分器程序
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#define LEDData P0
unsigned char code
LEDCode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char minit,second,count,count1; //·Ö£¬Ã룬¼ÆÊýÆ÷
sbit add1=P1^0; //¼×¶Ó¼Ó·Ö
sbit dec1=P1^1; //¼×¶Ó¼õ·Ö
sbit exchange=P1^2; //»»³¡
sbit add2=P1^3; //ÒÒ¶Ó¼Ó·Ö
sbit dec2=P1^4; //ÒÒ¶Ó¼õ·Ö
sbit secondpoint=P0^7; //ÃëµãÉÁ¶¯
sbit led1=P2^7;
sbit led2=P2^6;
sbit led3=P2^5;
sbit led4=P2^4;
sbit led5=P2^3;
sbit led6=P2^2;
sbit led7=P2^1;
sbit led8=P2^0;
sbit led9=P3^7;
sbit led10=P3^6;
sbit led11=P3^5;
sbit alam=P1^7; //±¨¾¯
bit playon=0; //±ÈÈü½øÐбê־룬1±íʾ¿ªÊ¼
bit timeover=0; //±ÈÈü½áÊø±ê־룬1±íʾ½áÊø
bit AorB=0; //¼×¡¢ÒÒ¶Ó½»»»Î»Öñê־λ
bit halfsecond=0; //°ëÃë±ê־λ
unsigned int scoreA; //¼×¶ÓµÃ·Ö
unsigned int scoreB; //ÒҶӵ÷Ö
void Delay5ms(void)
{
unsigned int i;
for(i=100;i>0;i--);
}
void display(void)
{
LEDData=LEDCode[minit/10];
led1=0;
Delay5ms();
led1=1;
LEDData=LEDCode[minit%10];
led2=0;
Delay5ms();
led2=1; //ÏÔʾʱ¼ä·Ö
if(halfsecond==1)
LEDData=0x80;
else
LEDData=0x00;
led2=0;
Delay5ms();
led2=1;
secondpoint=0; //ÃëµãÉÁ¶¯
LEDData=LEDCode[second/10];
led3=0;
Delay5ms();
led3=1;
LEDData=LEDCode[second%10];
led4=0;
Delay5ms();
led4=1; //ÏÔʾʱ¼äÃë
if(AorB==0)
LEDData=LEDCode[scoreA/100];
else
LEDData=LEDCode[scoreB/100];
led5=0;
Delay5ms();
led5=1; //ÏÔʾ1×éµÄ·ÖÊý°Ùλ
if(AorB==0)
LEDData=LEDCode[(scoreA%100)/10];
else
LEDData=LEDCode[(scoreB%100)/10];
led6=0;
Delay5ms();
led6=1; //ÏÔʾ1×éµÄ·ÖÊýʮλ
if(AorB==0)
LEDData=LEDCode[scoreA%10];
else
LEDData=LEDCode[scoreB%10];
led7=0;
Delay5ms();
led7=1; //ÏÔʾ1×éµÄ·ÖÊý¸öλ
if(AorB==1)
LEDData=LEDCode[scoreA/100];
else
LEDData=LEDCode[scoreB/100];
led8=0;
Delay5ms();
led8=1; //ÏÔʾ2×éµÄ·ÖÊý°Ùλ
if(AorB==1)
LEDData=LEDCode[(scoreA%100)/10];
else
LEDData=LEDCode[(scoreB%100)/10];
led9=0;
Delay5ms();
led9=1; //ÏÔʾ2×éµÄ·ÖÊýʮλ
if(AorB==1)
LEDData=LEDCode[scoreA%10];
else
LEDData=LEDCode[scoreB%10];
led10=0;
Delay5ms();
led10=1; //ÏÔʾ2×éµÄ·ÖÊý¸öλ
}
//==============°´¼ü¼ì²â³ÌÐ=====================ò
void keyscan(void)
{
if(playon==0)
{
if(add1==0)
{
display();
if(add1==0);
{
if(minit<99)
minit++;
else
minit=99;
}
do
display();
while(add1==0);
}
if(dec1==0)
{
display();
if(dec1==0);
{
if(minit>0)
minit--;
else
minit=0;
}
do
display();
while(dec1==0);
}
if(add2==0)
{
display();
if(add2==0);
{
if(second<59)
second++;
else
second=59;
}
do
display();
while(add2==0);
}
if(dec2==0)
{
display();
if(dec2==0);
{
if(second>0)
second--;
else
second=0;
}
do
display();
while(dec2==0);
}
if(exchange==0)
{
display();
if(exchange==0);
{
TR1=0; //¹Ø±ÕT1¼ÆÊýÆ÷
alam=1; //¹Ø±Õ±¨¾¯
AorB=~AorB; //¿ªÆô½»»»
minit=15; //ʱ¼äÔ¤ÉèΪ15·Ö
second=0;
}
do
display();
while(exchange==0);
}
}
else
{
if(add1==0)
{
display();
if(add1==0);
{
if(AorB==0)
{
if(scoreA<999)
scoreA++;
else
scoreA=999;
}
else
{
if(scoreB<999)
scoreB++;
else
scoreB=999;
}
}
do
display();
while(add1==0);
}
if(dec1==0)
{
display();
if(dec1==0);
{
if(AorB==0)
{
if(scoreA>0)
scoreA--;
else
scoreA=0;
}
else
{
if(scoreB>0)
scoreB--;
else
scoreB=0;
}
}
do
display();
while(dec1==0);
}
if(add2==0)
{
display();
if(add2==0);
{
if(AorB==1)
{
if(scoreA<999);
scoreA++;
else
scoreA=999;
}
else
{
if(scoreB<999);
scoreB++;
else
scoreB=999;
}
}
do
display();
while(add2==0);
}
if(dec2==0)
{
display();
if(dec2==0)£»
{
if(AorB==1)
{
if(scoreA>0)
scoreA--;
else
scoreA=0;
}
else
{
if(scoreB>0);
scoreB--;
else
scoreB=0;
}
}
do
display();
while(dec2==0);
}
}
}
//=========Ö÷º¯Êý===========
void main(void)
{
TMOD=0x11;
TL0=0Xb0;
TH0=0X3c;
TL1=0Xb0;
TH1=0X3c;
minit=15;
second=0;
EA=1;
ET0=1;
ET1=1;
TR0=0;
TR1=0;
EX0=1;
IT0=1;
IT1=1;
//EX1=1;
PX0=1;
//PX1=1;
PT0=0;
P1=0Xff;
P3=0Xff;
while(1)
{
keyscan();
display();
}
}
void PxInt0(void) interrupt0
{
Delay5ms();
EX0=0;
alam=1;
TR1=0;
if(timeover==1)
{
timeover=0;
}
if(playon==0)
{
playon=1; //¿ªÊ¼±ê־λ
TR0=1; //¿ªÆô¼Æʱ
}
else
{
playon=0; //¿ªÊ¼±ê־λÇåÁã
TR0=0; //ÔÝÍ£¼Æʱ
}
EX0=1; //¿ªÖжÏ
}
void PxInt1(void) interrupt2
{
Delay5ms();
EX1=0; //¹ØÖжÏ
if(timeover==1) //±ÈÈü½áÊø±êÖ¾
{
TR1=0; //¹Ø±ÕT1¼ÆÊýÆ÷
alam=1; //¹Ø±¨¾¯
AorB=~AorB; //¿ªÆô½»»»
minit=15; //Ô¤Éèʱ¼äΪ15min
second=0;
}
EX1=1; //¿ªÖжÏ
}
//======ÖжÏÎå·þÎñº¯Êý============
void time0_int(void) interrupt1
{
TL0=0Xb0;
TH0=0X3c;
TR0=1;
count++;
if(count==10)
{
halfsecond=0;
}
if(count==20)
{
count=0;
halfsecond=1;
if(second==0)
{
if(minit>0);
{
second=59;
minit--;
}
else
{
timeover=1;
playon=0;
TR0=0;
TR1=1;
}
}
else
second--;
}
}
void time1_int(void) interrupt3
{
TL1=0Xb0;
TH1=0X3c;
TR1=1;
count1++;
if(count1==10)
{
alam=0;
}
if(count1==20)
{
count1=0;
alam=1;
}
}
程序要求是设计一个篮球计时计分器,6个LED显示两个队伍的分数,4个LED显示时间的倒计时,有独立按键控制加减分,计时调整和开始暂停,结束发生警报。
求大家都来看看我的error怎么解决。本来就几个error。改对了反而变成了好几十个。感觉无力- -
篮球.c(348): error C132: 'EX1': not in formal parameter list
篮球.c(349): error C141: syntax error near 'if'
篮球.c(349): error C141: syntax error near '==', expected ')'
篮球.c(351): error C231: 'TR1': redefinition
篮球.c(351): error C231: 'TR1': redefinition
篮球.c(352): error C231: 'alam': redefinition
篮球.c(352): error C231: 'alam': redefinition
篮球.c(353): error C279: 'AorB': multiple initialization
篮球.c(353): error C231: 'AorB': redefinition
篮球.c(353): error C247: non-address/-constant initializer
篮球.c(354): error C231: 'minit': redefinition
篮球.c(355): error C231: 'second': redefinition
篮球.c(356): error C141: syntax error near '}'
篮球.c(357): error C231: 'EX1': redefinition
篮球.c(357): error C231: 'EX1': redefinition
篮球.c(358): error C141: syntax error near '}'
篮球.c(361): error C132: 'interrupt1': not in formal parameter list
篮球.c(361): error C141: syntax error near '{'
篮球.c(362): error C244: 'TL0': can't initialize, bad type or class
篮球.c(362): error C132: 'TL0': not in formal parameter list
篮球.c(363): error C244: 'TH0': can't initialize, bad type or class
篮球.c(363): error C132: 'TH0': not in formal parameter list
篮球.c(364): error C279: 'TR0': multiple initialization
篮球.c(364): error C244: 'TR0': can't initialize, bad type or class
篮球.c(364): error C132: 'TR0': not in formal parameter list
篮球.c(365): error C132: 'count': not in formal parameter list
篮球.c(365): error C141: syntax error near '++'
篮球.c(368): error C279: 'halfsecond': multiple initialization
篮球.c(368): error C244: 'halfsecond': can't initialize, bad type or class
篮球.c(368): error C132: 'halfsecond': not in formal parameter list
篮球.c(369): error C141: syntax error near '}'
篮球.c(370): error C141: syntax error near '==', expected ')'
篮球.c(372): error C231: 'count': redefinition
篮球.c(373): error C279: 'halfsecond': multiple initialization
篮球.c(373): error C231: 'halfsecond': redefinition
篮球.c(374): error C141: syntax error near 'if'
篮球.c(374): error C141: syntax error near '==', expected ')'
篮球.c(376): error C141: syntax error near '>', expected ')'
篮球.c(378): error C279: 'second': multiple initialization
篮球.c(379): error C129: missing ';' before '--'
篮球.c - 77 Error(s), 0 Warning(s).
篮球计时计分器c语言程序,C51的篮球计时计分器程序相关推荐
- c语言单片机计时程序,C51单片机秒表计时(C语言)
<C51单片机秒表计时(C语言)>由会员分享,可在线阅读,更多相关<C51单片机秒表计时(C语言)(4页珍藏版)>请在人人文库网上搜索. 1.南开大学滨海学院C51嵌入式软件设 ...
- 51单片机c语言秒表,C51单片机秒表计时(C语言).doc
C51单片机秒表计时(C语言).doc 南开大学滨海学院C51嵌入式软件设计(C语言) 题目计时秒表 l 功能描述本设计实现在99秒内的秒表计时,一个按键实现开始.暂停.复位.l 原理概述P1接四位七 ...
- 通讯rs232c语言编程,基于C51的RS232基本通信程序
由于即将用到C#与单片机的通信程序,我回头使用了STC12系列的单片机,暂时停止AVR.因为AVR的编程器不属于RS232接口通信,弄起来麻烦.为了兼容性,我把程序的名称定义为和AVR里的名称一样,而 ...
- 程序员语言也有鄙视链!某美团程序员爆料:筛选简历时,用go语言的基本不看!网友:当韭菜还当出优越感了!...
程序员使用的语言有鄙视链吗?有人说有,有人说没有.一个美团员工发帖说,筛选简历时用go语言的基本不看.短短一句话,把对go语言的鄙视体现得淋漓尽致,难道go语言真的不如其他语言? 和他一样想法的前阿里 ...
- 关于C#开发山寨操作系统,程序语言,浏览器,IDE,Office,Photoshop等大型程序的可行性歪论及意义...
首先,起这么个大标题不是为了眼球,也决非本人自大,本人对技术是很一般的也就是个普通人.不过因为受一些言论,贴子,新闻等综合思考而产生. 有些人认为C#这不行那不行,只能做做"企业管理&quo ...
- error C2057: expected constant expression (C语言中数组的大小可以在程序运行时定义吗? )
数组的大小可以在程序运行时定义吗? 不.在数组的定义中,数组的大小必须是编译时可知的,不能是在程序运行时才可知的.例如,假设i是一个变量,你就不能用i去定义一个数组的大小: char array[i] ...
- java语言与www技术形成性考核册_电大Java语言与WWW技术形成性考核程序题
电大JAVA语言与WWW技术形成性考核程序题一.写出下列程序完成的功能1.PUBLICCLASSSUM{PUBLICSTATICVOIDMAINSTRINGARGS{INTSUM0FORINTI1IM ...
- c语言循环程序设计教案,10 《C语言程序设计》教案 第三章 程序的控制结构(6)—循环结构 while和do while.doc...
10 <C语言程序设计>教案 第三章 程序的控制结构(6)-循环结构 while和do while.doc C 语言程序设计课程教案表 授课题目 第三章 程序的控制结构 (6) 循环结构 ...
- c语言如何快速看懂别人的程序,探究如何快速看懂单片机程序方法
在现实中,我相信有很多刚刚接触单片机的同学,简直是无从下手,打开一个程序,更会被复杂的结构和密密麻麻的代码吓到,产生退缩的想法,这篇文章带你了解一下单片机程序. 我对单片机的总结:"单片机其 ...
- c语言pow函数用法_C语言基础的不能再基础的程序知识!“hello world”!
涉及到的知识点有:include有两种用法.{}大括号用法解释.C语言自定义名字的要求. c语言库函数printf的解释.编译错误有两种.调用system函数.c语言编译过程. 操作系统结构.指令集中 ...
最新文章
- 人工智能实践:TensorFlow笔记学习(五)—— 全连接网络基础
- md5-linux_shell
- java sessionmanager_java.lang.IllegalStateException:没有SessionManager
- 282天,汇付天下“冲上云霄”
- log4cplus导致主进程不能退出问题解决
- batch批处理程序easyadd——追加单行文本到指定txt文件末尾
- 最惨2019:超300家创业公司死亡名录
- 计算机比特块的输出概念,第1讲-比特的概念及计算机的组成原理.ppt
- ht1621b和单片机电平匹配_基于HT1621B段式液晶模块的驱动应用
- NOIP2018 游记
- PC/UVA 110405/10026 Shoemaker's problem
- python写一个简单的CMS识别
- Gitlab代码库自动同步到Github
- 上课笔记-机器学习(4)-泰坦尼克号沉没乘客存活分析
- 帝国cms生成html网站地图的教程步骤
- 若依微服务版登录流程源码分析1
- Dolphinscheduler 学习笔记
- android 重力感应view,Android重力感应示例
- 用大气噪声生成Java中的随机数
- 全球9个国家“房奴”的不同人生,值得一读!
热门文章
- js实现图片放大镜效果——简单方法
- 【计算机组成原理】中央处理器(三)—— 数据通路
- vue移动端实现word在线预览
- 解决libcrypto.so.1.0.0 动态库找不到的问题
- vue json对象转数组_年薪百万之路--第六十七天 Vue入门
- Go-Kit实现莫斯电码转换
- 中国鲷鱼养殖产量和捕捞产分析,养殖产业区域集中度高「图」
- 基于Java+Springboot+mybatis+lyaui的学科竞赛管理系统设计和实现
- 设计模式、重构、编程规范等的经典书籍书籍推荐
- JDY-10M组网 蓝牙MESH组网