- #define uchar unsigned char //快捷定义
- #define uint unsigned int //快捷定义
- #define duan P2 //数码管段选接口
- #define wei P3 //数码管位选接口
- sbit ledH=P0^2; //指示红灯接口
- sbit ledL=P0^3; //指示绿灯接口
- sbit Frst=P1^4; //按键1
- sbit Second=P1^5; //按键2
- sbit Third=P1^6; //按键3
- sbit Forth=P1^7; //按键4
- sbit k1=P1^0; //start按键
- sbit k2=P1^1; //reset按键
- uchar i=0; //数码管显示计时
- //uchar qinflag; //移位标志
- uchar code number[20]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x8c,0xff,0xbf,0xcf}; //0~9,a,b,c,d,e,f,p,不显示,-,
- iuchar code weizi[11]={0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x10,0x20};//位选数据//
- uchar code error[10]={0xff,0xaf,0xc0,0xaf,0xaf,0x86,0xff,0xff,0xff};//erroruchar displayData[11];
- //uchar weishu;
- char time;
- uchar qdShijian; //时间计时
- uchar xuanshou; //选手编号
- bit qdQidong; //抢答启动
- //bit dtQidong; //答题启动
- bit select; //选择
- uint count; //定时计时变量
- void init(); //初始化
- uchar scanzhi(); //获取按键值
- void display(); //数码管显示
- void duzhichuli(); //数据处理
- =================================================
- void keyscan(){
- if(k1==0) //检测按键K1是否按下开始
- { //Delay10ms(); //消除抖动
- // while(k1==0); //松手检测
- qdQidong = 1; //启动抢答
- qdShijian = 20;//倒计时20秒
- select = 1; //启动选择
- ledL = 1; //绿灯亮 }
- if(k2==0) //检测按键K2是否按下复位
- { ledL = 0; //绿灯灭
- ledH = 0; //红灯灭
- select = 1;//选择
- for(i=1;i<12;i++) //显示数据清零
- displayData[i]=number[0]; }
- if(select == 1 && qdQidong == 1) //抢答处理
- { if(Frst==0) //检测按键1号选手
- { select = 0; //退出选择
- // dtShijian = 30; //倒计时30秒
- // dtQidong = 1; //倒计时启动
- qdQidong = 0; //抢答停止
- xuanshou = 1; //选手1
- time=0;
- displayData[1] = number[10]; //显示a
- displayData[2] = number[xuanshou]; //显示编号 }
复制代码
displaydate【i】=number(0)是啥意思
|