在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統 > 設計應用 > AVR128的程序——矩陣按鍵

            AVR128的程序——矩陣按鍵

            作者: 時間:2016-11-22 來源:網絡 收藏
            #include
            #include
            #define uchar unsigned char
            #define uint unsigned int
            void Delayms(uint MS);
            uchar key_scan(void);
            void init_io(void);
            uchar led_discode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
            0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xff};
            uchar key_val=0;
            void main (viod)
            {
            uchar key_io;
            init_io();
            while(1)
            {
            PORTD=0XF0;
            Delayms(5);
            key_io=PIND & 0xf0;
            if(key_io !=0xf0)
            {
            PORTD=0XF0;
            Delayms(1);
            key_io=PIND & 0xf0;
            if(key_io !=0xf0)
            {
            key_val=key_scan();
            key_val |= key_io ;
            }
            switch(key_val)
            {
            case 0xee: key_val=0x00; break; //按鍵K1
            case 0xde: key_val=0x01; break; //按鍵K2
            case 0xbe: key_val=0x02; break; //按鍵K3
            case 0x7e: key_val=0x03; break; //按鍵K4
            case 0xed: key_val=0x04; break; //按鍵K5
            case 0xdd: key_val=0x05; break; //按鍵K6
            case 0xbd: key_val=0x06; break; //按鍵K7
            case 0x7d: key_val=0x07; break; //按鍵K8
            case 0xeb: key_val=0x08; break; //按鍵K9
            case 0xdb: key_val=0x09; break; //按鍵K10
            case 0xbb: key_val=0x0a; break; //按鍵K11
            case 0x7b: key_val=0x0b; break; //按鍵K12
            case 0xe7: key_val=0x0c; break; //按鍵K13
            case 0xd7: key_val=0x0d; break; //按鍵K14
            case 0xb7: key_val=0x0e; break; //按鍵K15
            case 0x77: key_val=0x0f; break; //按鍵K16
            }
            }
            PORTD=0XF0;
            key_io=PIND & 0xf0;
            while(key_io !=0xf0)
            {
            key_io=PIND & 0xf0;
            }
            PORTC=led_discode[key_val];
            }
            }
            void init_io(void)
            {
            DDRA=0XFF;
            PORTA=0XFF;
            DDRB=0XFF;
            PORTB=0XFF;
            DDRC=0XFF;
            PORTC=0XFF;
            DDRD=0X0F;
            PORTD=0XF0;
            DDRF=0X0E;
            PORTF=0X0E;
            PORTF&=0XF7;
            DDRB |=0X10;
            PORTB|=0X10;
            }
            uchar key_scan(void)
            {
            uchar m,temp=0xf7;
            for(m=0;m<4;m++)
            {
            PORTD=temp | 0xf0;
            Delayms(1);
            if((PIND & 0XF0)!=0XF0)
            return(temp & 0x0f);
            temp>>=1;
            }
            }
            void Delayms(uint MS)
            {
            uint i,j;
            for( i=0;i
            for(j=0;j<1141;j++);
            }


            關鍵詞: AVR128矩陣按

            評論


            技術專區(qū)

            關閉