51单片机程序抢答器

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

/*此程序在SP-518USB开发板上测试过 laosong */

/****************************************************************

程序名称: 数码管显示0123456789
说明:使用本程序你必须把 SE3设置为2-3短接 SE4设置为2-3短接

*****************************************************************/


/*头文件*/
#include
#include
#define uint unsigned int
#define uchar unsigned char
#define nop() _nop_()


uchar code dd[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

uchar code aa[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
sbit u=P3^3;
sbit o=P2^1;
void main()
{ uchar cc;

P1=0xff ;
P0=0x00;
u=1;
o=1;

while(1)
{cc=0;
if(P1!=0xff)
{
cc=P1;

if(cc==aa[0]){P0=dd[1];}
if(cc==aa[1]){P0=dd[2];}
if(cc==aa[2]){P0=dd[3];}
if(cc==aa[3]){P0=dd[4];}
if(cc==aa[4]){P0=dd[5];}
if(cc==aa[5]){P0=dd[6];}
if(cc==aa[6]){P0=dd[7];}
if(cc==aa[7]){P0=dd[8];}

while(u){
;}
o=0;
P0=0x00; }


}

}












相关文档
最新文档