小邓BLOG » 键盘扫描

? 看着书写的!

#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit key1=P1^0;
sbit key2=P1^1;
uchar code table[]={
0×3f,0×06,0×5b,0×4f,
0×66,0×6d,0×7d,0×07,
0×7f,0×6f};
uchar num;
void yans(uint);
void xians(uchar);
void keyscan();

?void main()
?{
??while(1)
??{
???keyscan();
???xians(num);

??}
?}

?void keyscan()
?{
?? if(key1==0)
?? {
?? ?yans(10);
???if(key1==0)
???{
????num++;
????if(num==60)
?????num=0;
????while(!key1);?
???}
?? }
?? if(key2==0)
?? {
?? ?yans(10);
???if(key2==0)
???{
????if(num==0)
?????num=60;
?????num–;
????while(!key2);
???}
?? }??
?}

?void xians(uchar shenm)
?{
?? uchar shi,ge;
?? shi=shenm/10;
?? ge=shenm%10;
????????
?? P1=0xfe;
?? P2=table[shi];
?? yans(5);
?? P1=0xff;
?? P2=table[ge];
?? yans(5);

?}

?void yans(uint xms)
?{
??uint i,j;
??for(i=xms;i>0;i–)
???for(j=110;j>0;j–);
?}

郑重声明:资讯 【小邓BLOG » 键盘扫描】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——