欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
16按鍵數字顯示程序
[打印本頁]
作者:
唐長老
時間:
2016-12-11 21:29
標題:
16按鍵數字顯示程序
16按鍵.png
(99.96 KB, 下載次數: 44)
下載附件
16按鍵Protues原理圖
2016-12-11 21:28 上傳
#include <regx51.h>
void delayms(unsigned int i)
{
unsigned char k;
while(i--)
for(k=0;k<120;k++);
}
char scan_key ();
void main()
{
unsigned char led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
unsigned char i;
P1=0xff;
P0=0xff;
while(1)
{
i=scan_key();
if(i==-1)continue;
else
P1=led[i];
}
}
char scan_key ()
{
char i, temp,m,n;
bit find=0;
P2=0xf0;
i=P0;
i&0x0f;
if(i!=0x0f)
{
delayms(10);
i=P0;
i&0x0f;
if(i!=0x0f)
{
for(i=0;i<4;i++)
{
P2=0xfe<<i;
temp=~P0;
temp=temp&0x0f;
if(temp!=0x00)
{
m=i;
find=1;
switch(temp)
{
case 0x01:n=0;break;
case 0x02:n=1;break;
case 0x04:n=2;break;
case 0x08:n=3;break;
default:break;
}
break;
}
}
}
}
if(find==0) return -1;
else return(n*4+m);
}
復制代碼
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1