Presentation is loading. Please wait.

Presentation is loading. Please wait.

Decoding and Using a 4x4 Keyboard

Similar presentations


Presentation on theme: "Decoding and Using a 4x4 Keyboard"— Presentation transcript:

1 Decoding and Using a 4x4 Keyboard
18/02/2019 Tim Sumner, Imperial College, Rm: 1009, x47552

2 The Keyboard 1 2 3 F 4 5 6 7 8 9 D A B C E By Pressing a button you
connect one of the white lines to one of the black lines. But you don’t know which. 1 2 3 F 4 5 6 E 7 8 9 D A B C 8 lines corresponding to 4 rows and 4 columns 18/02/2019 Tim Sumner, Imperial College, Rm: 1009, x47552

3 The PCB of the Key-Board
From this picture you get an idea of what exactly happens in the keyboard. IT IS ALL PASSIVE: No ICs no Transistors The buttons connect one row with one column! 18/02/2019 Tim Sumner, Imperial College, Rm: 1009, x47552

4 Decoding the Key-Board
P O R T B 5-7 1 2 3 F 4 5 6 E 7 8 9 D A B C +5 Volts PORTB 0-4 18/02/2019 Tim Sumner, Imperial College, Rm: 1009, x47552

5 Tim Sumner, Imperial College, Rm: 1009, x47552
Pull-up Resistors on ATmeag103 Ports Port Example: DDRA : Direction Reg. PORTA : OUTPUT Reg. PINA : INPUT (no Reg.) Notice that each pin in PORTB is independent! 18/02/2019 Tim Sumner, Imperial College, Rm: 1009, x47552

6 Tim Sumner, Imperial College, Rm: 1009, x47552
How to configure PORTB Configure PORTB 5-7 as inputs and PORTB 0-4 as outputs (DDRB: $0F) (2) Set the PORT REGISTERS in such a way so that the inputs have pull up resistors and the outputs drive low (PORTB: $F0) 18/02/2019 Tim Sumner, Imperial College, Rm: 1009, x47552

7 Tim Sumner, Imperial College, Rm: 1009, x47552
Task Plan I Write a routine that decodes the key on the 4x4 Keyboard and tells you what key was pressed on the LCD display But first you need to know exactly what does the keyboard do internally 18/02/2019 Tim Sumner, Imperial College, Rm: 1009, x47552

8 Tim Sumner, Imperial College, Rm: 1009, x47552
Task Plan II STEP1: Set the pullup resistors on the 4 bits of port B and connect the 4 pins of the keyboard (through resistor packs). At this point the 4 lines of the keyboard are held high by the pullup resistors (your LEDs should be dark). STEP2: Connect the rest of keyboard pins to 4 PORTB pins (resistor packs). STEP3: Push a keyboard button and have a program that drives the PORTB outputs low one at a time (1110,1101,1011,0111). This should tell you which Pin does is connected with which when you press that button. 18/02/2019 Tim Sumner, Imperial College, Rm: 1009, x47552

9 Tim Sumner, Imperial College, Rm: 1009, x47552
3 F 4 5 6 E 7 8 9 D A B C 5V OUT IN Row 2 Pressed, Col ? Not Col 3 Found column = 2 Column Row Pull-up resistors 5 This button pressed. Column wire connected to row wire 18/02/2019 Tim Sumner, Imperial College, Rm: 1009, x47552

10 Tim Sumner, Imperial College, Rm: 1009, x47552
Keyboard  ATmega103 Port We need a reliable setup where the ATmega103 interprets relatively quickly any key pressed on the keyboard . Noice that the microprocessor is faster than your finger and can ‘see’ the bouncing up and down that happens when you press the a button of the keyboard. So you need to check if what you read is stable Two questions: (1) What type of hardware setup do we need ? (2) What kind of driver software do we need ? 18/02/2019 Tim Sumner, Imperial College, Rm: 1009, x47552


Download ppt "Decoding and Using a 4x4 Keyboard"

Similar presentations


Ads by Google