Presentation is loading. Please wait.

Presentation is loading. Please wait.

Matrix Key Pad Configuration Lecturer: Reza Arjmandi Autumn 2015 Lecture 6: Introduction Matrix KeyPad Configuration.

Similar presentations


Presentation on theme: "Matrix Key Pad Configuration Lecturer: Reza Arjmandi Autumn 2015 Lecture 6: Introduction Matrix KeyPad Configuration."— Presentation transcript:

1 Matrix Key Pad Configuration Lecturer: Reza Arjmandi Autumn 2015 Lecture 6: Introduction Matrix KeyPad Configuration

2 Matrix KeyPad

3 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 11 12 13 14 15 Matrix KeyPad: 4*4 4*3 3*3 …

4 Matrix KeyPad-Scan Methode Click Output Input 0 0 0 0 1 0 11 0xBB Code: Input Output 0 0 00 1 1 0 1 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 11 12 13 14 15 For number 10

5 Matrix KeyPad-Table Code For 4*4 پورت متصل شده به صفحه کلید شماره کلید فشرده شده bit7bit6bit5bit4bit3bit2bit1bit0 کد تولید شده ستون ها سطرها C4C3C2C1R4R3R2R1 0 11101110 0xEE 1 11011110 0xDE 2 10111110 0xBE 3 01111110 0x7E 4 11101101 0xED 5 11011101 0xDD 6 10111101 0xBD 7 01111101 0x7D 8 11101011 0xEB 9 11011011 0xDB 10 10111011 0xBB 11 01111011 0x7B 12 11100111 0xE7 13 11010111 0xD7 14 10110111 0xB7 15 01110111 0x77 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 11 12 13 14 15 Matrix KeyPad 4*4 Not Clicked Code: 0xFF

6 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; } 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 11 12 13 14 15 10

7 Matrix KeyPad-Table Code For 3*3 پورت متصل شده به کامپیوتر شماره کلید فشرده شده bit5bit4bit3bit2bit1bit0 کد تولید شده ستون هاسطر ها C3C2C1R3R2R1 0 110110 0x36 1 101110 0x2E 2 011110 0x1E 3 111110 0x35 4 110101 0x2D 5 101101 0x1D 6 011101 0x33 7 111101 0x2B 8 110011 0x1B 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 Matrix KeyPad 3*3

8 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:111000 key=(PINC&0x38); DDRC=0x38; //bin:111000 PORTC=0x07;//bin:111 key|=(PINC&0x07); return key; } 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8

9 Matrix KeyPad-Table Code For 4*3 پورت متصل شده به کامپیوتر شماره کلید فشرده شده bit6bit5bit4bit3bit2bit1bit0 کد تولید شده ستون هاسطر ها C3C2C1R4R3R2R1 0 1101110 0xE6 1 1011110 0x5E 2 0111110 0x3E 3 1111110 0x6D 4 1101101 0x5D 5 1011101 0x3D 6 0111101 0x6B 7 1111101 0x5B 8 1101011 0x3B 9 1011011 0x67 10 0111011 0x57 11 1111011 0x37 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 11 Matrix KeyPad 4*3

10 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:1110000 key=(PINC&0x70); DDRC=0x70; //bin:1110000 PORTC=0x0F;//bin:1111 key|=(PINC&0x0F); return key; } 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 11

11 #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 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 11 12 13 14 15 +VCC

12 Matrix KeyPad-Better Performance Scan 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 11 12 13 14 15 اسکن مداوم وقفه

13 Matrix KeyPad Configuration IC 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 11 12 13 14 15 20 19 18 17 16 15 14 13 12 11 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

14 Contact us www.e-system.ir Info@e-system.ir


Download ppt "Matrix Key Pad Configuration Lecturer: Reza Arjmandi Autumn 2015 Lecture 6: Introduction Matrix KeyPad Configuration."

Similar presentations


Ads by Google