亚洲春色中文字幕久久久-三上亚,91精品国产亚一区二区三区,久久久九色综合亚洲成色777,涩涩视频下载,国产午夜亚洲精品午夜鲁丝片,国产精品A一区二区三区腾讯导航,影音先锋色情AV在线看片,蜜臀国产在线视频,极品少妇高潮啪啪无码吴梦梦 ,精品人妻无码一区二区三区手机版

標(biāo)題: 同時(shí)使用獨(dú)立按鍵和矩陣按鍵出現(xiàn)了混亂,該怎么辦 [打印本頁]

作者: 春天的花蕊    時(shí)間: 2017-3-14 22:11
標(biāo)題: 同時(shí)使用獨(dú)立按鍵和矩陣按鍵出現(xiàn)了混亂,該怎么辦
同時(shí)使用獨(dú)立按鍵和矩陣按鍵出現(xiàn)了混亂,該怎么辦。求大神指教

作者: admin    時(shí)間: 2017-3-14 22:18
你的源碼貼出來看一下
作者: tzw750303    時(shí)間: 2017-3-14 22:23
可以把按鍵值合并,你按鍵掃描程序有問題吧
作者: 春天的花蕊    時(shí)間: 2017-3-14 22:23
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit key1=P3^4;
sbit key2=P3^5;
sbit key3=P3^6;
sbit key4=P3^7;
sbit dula=P2^6;
sbit wela=P2^7;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,                  
0x39,0x5e,0x79,0x71};

void delayms(uint xms)
{
        uint i,j;
        for(i=xms;i>0;i--)
                for(j=110;j>0;j--);
}

void display(uint num)
{
        P0=table[num];
        dula=1;
        dula=0;
}       

void matrikeyscan()
{
        uint temp,key;
        P3=0xfe;
        temp=P3;
        temp=temp&0xf0;
        if(temp!=0xf0)
        {         
                delayms(10);
                temp=P3;
                temp=temp&0xf0;
                if(temp!=0xf0)
                {
                       
                        temp=P3;
                        switch(temp)
                        {
                                case 0xee:key=0;break;
                                case 0xde:key=1;break;
                                case 0xbe:key=2;break;
                                case 0x7e:key=3;break;
                        }
                        while(temp!=0xf0)
                        {
                                temp=P3;
                                temp=temp&0xf0;
                        }
                        display(key);
                }
        }       
        P3=0xfd;
        temp=P3;
        temp=temp&0xf0;
        if(temp!=0xf0)
        {                                  
                delayms(10);
                temp=P3;
                temp=temp&0xf0;
                if(temp!=0xf0)
                {
                        temp=P3;
                        switch(temp)
                        {
                                case 0xed:key=4;break;
                                case 0xdd:key=5;break;
                                case 0xbd:key=6;break;
                                case 0x7d:key=7;break;
                        }
                        while(temp!=0xf0)
                        {
                                temp=P3;
                                temp=temp&0xf0;
                        }
                        display(key);
                }
        }
        P3=0xfb;
        temp=P3;
        temp=temp&0xf0;
        if(temp!=0xf0)
        {         
                delayms(10);
                temp=P3;
                temp=temp&0xf0;
                if(temp!=0xf0)
                {
                       
                        temp=P3;
                        switch(temp)
                        {
                                case 0xeb:key=8;break;
                                case 0xdb:key=9;break;
                                case 0xbb:key=10;break;
                                case 0x7b:key=11;break;
                        }
                        while(temp!=0xf0)
                        {
                                temp=P3;
                                temp=temp&0xf0;
                        }
                        display(key);
                }
        }       

}  

void keyscan()
{         
        uchar  key;
        if(key1==0)
        {
                delayms(10);
                if(key1==0)
                {
                        key=12;
                        while(!key1);
                        display(key);       
                }               
        }
        if(key2==0)
        {
                delayms(10);
                if(key2==0)
                {
                        key=13;
                        while(!key2);
                        display(key);       
                }               
        }
         matrikeyscan();
}


void main()
{
        P0=0;
        dula=1;
        dula=0;
        P0=0xc0;
        wela=1;
        wela=0;
        while(1)
        {
                 keyscan();       
               
        }
}

作者: 春天的花蕊    時(shí)間: 2017-3-14 22:24
matrixkeyscan()是在主函數(shù)中也不對(duì)
作者: 春天的花蕊    時(shí)間: 2017-3-14 22:29
tzw750303 發(fā)表于 2017-3-14 22:23
可以把按鍵值合并,你按鍵掃描程序有問題吧

可以合并嗎
作者: imxuheng    時(shí)間: 2017-3-15 17:38
為啥要用兩種方法
作者: 春天的花蕊    時(shí)間: 2017-3-15 18:02
imxuheng 發(fā)表于 2017-3-15 17:38
為啥要用兩種方法

我的板子矩陣鍵盤第四行不好用了
作者: ahshmj    時(shí)間: 2017-3-15 19:01
春天的花蕊 發(fā)表于 2017-3-15 18:02
我的板子矩陣鍵盤第四行不好用了

不好用了要找找原因。
作者: 淡然若夢(mèng)    時(shí)間: 2017-3-16 17:27
matrikeyscan();這個(gè)函數(shù)為啥要寫到keyscan中去?獨(dú)立按鍵建議使用狀態(tài)機(jī)
作者: yzwzfyz    時(shí)間: 2017-3-16 23:12
只要你的思路不混亂,就不會(huì)混亂。
作者: 看淡    時(shí)間: 2017-3-16 23:29
好長的程序。。。。。




歡迎光臨 (http://www.denmoz.com/bbs/) Powered by Discuz! X3.1