单片机实现动态数码管控制两位数字输入
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
main()
{
while(1)
{
unsigned charnum;
num=get_data;
if(n==0)
{
P0=0xfe;
wei=1;
wei=0;
P0=duanma[num];
duan=1;
duan=0;
n=1;
}
else if(n==1)
{
P0=0xfd;
wei=1;
wei=0;
P0=duanma[num];
unsignedintget_data();
delay(unsignedinta);
unsigned char n=0;
unsigned charduanma[10]={0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f};
//unsigned charweima[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
}。
if(!key2)
return 3;
}
else if(!key3)
{delay(10);
if(!key3)
return 4;
}
else if(!key4)
{delay(10);
if(!key4)
return 5;
}
else if(!key5)
{delay(10);
if(!key5)
return 6;
#include<reg51.h>
sbitkey0=P3^0;
sbitkey1=P3^1;
sbitkey2=P3^2;
sbitkey3=P3^3;
sbitkey4=P3^4;
sbitkey5=P3^5;
sbitkey6=P3^6;
sbitkey7=P3^7;
sbitduan=P2^2;
sbitwei=P2^3;
}
else if(!key6)
{delay(10);
if(!key6)
return 7;
}
else if(!key7)
{delay(10);
if(!key7)
return 8;
}
}
delay(unsignedinta)
{
unsignedintb;
for(;a>0;a--)
for(b=0;b<=100;b++);
duan=1;
duan=0;
n=0;
}Leabharlann Baidu
}
}
unsignedintget_data()
{
if(!key0)
{delay(10);
if(!key0)
return 1;
}
else if(!key1)
{delay(10);
if(!key1)
return 2;
}
else if(!key2)
{delay(10);
{
while(1)
{
unsigned charnum;
num=get_data;
if(n==0)
{
P0=0xfe;
wei=1;
wei=0;
P0=duanma[num];
duan=1;
duan=0;
n=1;
}
else if(n==1)
{
P0=0xfd;
wei=1;
wei=0;
P0=duanma[num];
unsignedintget_data();
delay(unsignedinta);
unsigned char n=0;
unsigned charduanma[10]={0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f};
//unsigned charweima[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
}。
if(!key2)
return 3;
}
else if(!key3)
{delay(10);
if(!key3)
return 4;
}
else if(!key4)
{delay(10);
if(!key4)
return 5;
}
else if(!key5)
{delay(10);
if(!key5)
return 6;
#include<reg51.h>
sbitkey0=P3^0;
sbitkey1=P3^1;
sbitkey2=P3^2;
sbitkey3=P3^3;
sbitkey4=P3^4;
sbitkey5=P3^5;
sbitkey6=P3^6;
sbitkey7=P3^7;
sbitduan=P2^2;
sbitwei=P2^3;
}
else if(!key6)
{delay(10);
if(!key6)
return 7;
}
else if(!key7)
{delay(10);
if(!key7)
return 8;
}
}
delay(unsignedinta)
{
unsignedintb;
for(;a>0;a--)
for(b=0;b<=100;b++);
duan=1;
duan=0;
n=0;
}Leabharlann Baidu
}
}
unsignedintget_data()
{
if(!key0)
{delay(10);
if(!key0)
return 1;
}
else if(!key1)
{delay(10);
if(!key1)
return 2;
}
else if(!key2)
{delay(10);