Matrix Key Pad Configuration Lecturer: Reza Arjmandi Autumn 2015 Lecture 6: Introduction Matrix KeyPad Configuration
Matrix KeyPad
Matrix KeyPad: 4*4 4*3 3*3 …
Matrix KeyPad-Scan Methode Click Output Input xBB Code: Input Output For number 10
Matrix KeyPad-Table Code For 4*4 پورت متصل شده به صفحه کلید شماره کلید فشرده شده bit7bit6bit5bit4bit3bit2bit1bit0 کد تولید شده ستون ها سطرها C4C3C2C1R4R3R2R xEE xDE xBE x7E xED xDD xBD x7D xEB xDB xBB x7B xE xD xB x Matrix KeyPad 4*4 Not Clicked Code: 0xFF
Matrix KeyPad-Scan Function For 4*4 Example: #include //include Header file unsigned char __flash code[16]= {0xEE,0xDE,0xBE,0x7E,0xED,0xDD,0xBD,0x7D,0xEB,0xDB,0xBB,0x7B,0xE7,0xD7,0xB7,0x77}; unsigned char scan(void); //function prototype void main(void) { char ch=scan(); for(unsigned char i=0;i<16;i++) { if(ch==code[i]) { lcd_puts(i); //display lcd } unsigned char scan(void) { unsigned char key; DDRC=0x0F; PORTC=0xF0; key=(PINC&0xF0); DDRC=0xF0; PORTC=0x0F; key|=(PINC&0x0F); return key; }
Matrix KeyPad-Table Code For 3*3 پورت متصل شده به کامپیوتر شماره کلید فشرده شده bit5bit4bit3bit2bit1bit0 کد تولید شده ستون هاسطر ها C3C2C1R3R2R x x2E x1E x x2D x1D x x2B x1B Matrix KeyPad 3*3
Matrix KeyPad-Scan Function For 3*3 Example: #include //include Header file unsigned char __flash code[9]= {0x36,0x2E,0x1E,0x35,0x2D,0x1D,0x33,0x2B,0x1B}; unsigned char scan(void); //function prototype void main(void) { … } unsigned char scan(void) { unsigned char key; DDRC=0x07; //bin:111 PORTC=0x38;//bin: key=(PINC&0x38); DDRC=0x38; //bin: PORTC=0x07;//bin:111 key|=(PINC&0x07); return key; }
Matrix KeyPad-Table Code For 4*3 پورت متصل شده به کامپیوتر شماره کلید فشرده شده bit6bit5bit4bit3bit2bit1bit0 کد تولید شده ستون هاسطر ها C3C2C1R4R3R2R xE x5E x3E x6D x5D x3D x6B x5B x3B x x x Matrix KeyPad 4*3
Matrix KeyPad-Scan Function For 4*3 Example: #include //include Header file unsigned char __flash code[12]={0x6E,0x5E, 0x3E,0x6D,0x5D,0x3D,0x6B,0x5B,0x3B,0x67,0x57,0x37}; unsigned char scan(void); //function prototype void main(void) { … } unsigned char scan(void) { unsigned char key; DDRC=0x0F; //bin:1111 PORTC=0x70;//bin: key=(PINC&0x70); DDRC=0x70; //bin: PORTC=0x0F;//bin:1111 key|=(PINC&0x0F); return key; }
#include unsigned char scan(void); unsigned char __flash code[]={0XEE,0XDE,0XBE,0X7E,0XED, 0XDD,0XBD,0X7D,0XEB,0XDB,0XBB,0X7B,0XE7,0XD7,0XB7,0X77}; unsigned char SEG[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92, 0x83,0xF8,0x80,0x90,0xA0,0x83,0xc6,0xA1,0x84,0x0E}; void main() { unsigned char data,i; DDRD=0XFF; while(1) { data=scan(); for(i=0;i<=15;i++) { if(data==code[i]) { PORTD=SEG[i]; break; } __delay_cycles(1000); } unsigned char scan(void) { … } Matrix KeyPad-Example VCC
Matrix KeyPad-Better Performance Scan اسکن مداوم وقفه
Matrix KeyPad Configuration IC VCC DATA OUT A DATA OUT B DATA OUT C DATA OUT D NC OUTPUT ENABLE DATA AVAILABLE COLUMN X1 COLUMN X2 ROW Y1 ROW Y2 ROW Y3 ROW Y4 NC OSCILLATOR KEBOUNCE MASK COLUMN X4 COLUMN X3 GND MM74C922
Contact us