1 / 10

Decoding and Using a 4x4 Keyboard

Decoding and Using a 4x4 Keyboard. The Keyboard. By Pressing a button you connect one of the row lines to one of the column lines . . 8 lines corresponding to 4 rows and 4 columns. The PCB of the Key-Board . From this picture you

jesse
Télécharger la présentation

Decoding and Using a 4x4 Keyboard

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Decoding and Using a 4x4 Keyboard Jordan Nash - Microprocessor Course

  2. The Keyboard By Pressing a button you connect one of the row lines to one of the columnlines. 8 lines corresponding to 4 rows and 4 columns Jordan Nash - Microprocessor Course

  3. The PCB of the Key-Board From this picture you Can see that the keyboard is all PASSIVE: No ICs no Transistors The buttons simply connect one row with one column! Jordan Nash - Microprocessor Course

  4. 0 0 0 0 Decoding what key is pressedStep 1: Row We can provide power to the four rows, and readout the data We write 0 to all columns In the example on the right (the 5 is pressed) we will see a 0 on row 2 and 1 on the rest of the rows We then have to determine which column has been pressed 1 0 1 1 Jordan Nash - Microprocessor Course

  5. 1 0 1 1 Step 2:Reading the Column If instead of providing power to the rows, we provide power to the columns we can determine which column has a key pressed We write 0 to all the rows In this case we will read 0 on column 1 and 1 on the other rows Hence we know that the ‘5’ was pressed as row 2 and col 1 have a key pressed 0 0 0 0 Jordan Nash - Microprocessor Course

  6. Pull-up Resistors on ATmeag128 Ports There are pull-up resistors present on-board. Which allow us to put power on the PORT pins. These need to be enabled by writing high levels to input pins. DDRx: Direction Reg. PORTx: OUTPUT Register PINx: INPUT (no Register) each pin in PORTx is independent! Jordan Nash - Microprocessor Course

  7. Reading the Keypad with the ATMega128 PORTE bits 4-7 Outputs We will use PORTE for both Reading the pins and providing the Power. This example is the initial configuration to read the row PORTE bits 0-3 Inputs Jordan Nash - Microprocessor Course

  8. Task Plan - Steps • Enable the pull-up resistors on bits 0-3 of PORTE and connect the 4 pins of the keyboard. Configure these pins as inputs, the 4 lines will be held high by the pull-up resistors. • Connect the rest of keyboard to pins 4-7 of PORTE and configure them as outputs. • Write a program that drives the output bits (4-7) of PORTE low all at once • read the 4 PORTE input pins (0-3). • Determine which row has a key pressed • Now configure bits 0-3 as outputs and bits 4-7 as inputs • Determine which column has a key pressed • Determine which key has been pressed • Echo the PORTE input to PORTB to use the LEDs to do a quick check of the keyboard. [also output to LCD.] Jordan Nash - Microprocessor Course

  9. How to configure PORTE for Step 1 • To configure PORTE 4-7 as outputs and PORTE 0-3 as inputs • set DDRE:$F0 • Set the PORT REGISTERS in such a way so that the inputs have pull up resistors and the outputs drive low • set PORTE:$0F Jordan Nash - Microprocessor Course

  10. Task • Write a routine that decodes the key on the 4x4 Keyboard and tells you what key was pressed on the LCD display • We need a reliable setup where the ATmega128 interprets relatively quickly any key pressed on the keyboard . • Notice 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. • Write a routine which reliably inputs a key press. • Write a routine which reliably inputs a string of key presses Jordan Nash - Microprocessor Course

More Related