You have no items in your shopping cart.

Subtotal: 0.00

How to Interface Keypad with ARM9-LPC2929 Development Kit

How to Interface Keypad with ARM9-LPC2929 Development Kit 

The ARM9-LPC2929 Primer kit is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports with Keil µvision4 with ULink2 Emulator.


NXP Philips Microcontroller, LPC2929 Primer Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 32-bit Microcontrollers. It integrates on board PS2, UART, ADC, PWM, Relay, Buzzer, I2C Seven Segment, I2C Serial EEPROM, Temperature Sensor LM35, Matrix Keypad, Switch, LED, Stepper Motor Driver, Traffic Light Controller, I2C RTC, and LCD & GLCD Display to create a stand-alone versatile test platform. User can easily engage in Primer in this platform, or use it as reference to application Primer


Keypad

keypad is a set of buttons arranged in a block or "pad" which usually bear digits, symbols and usually a complete set of alphabetical letters. If it mostly contains numbers then it can also be called a numeric keypad. Here we are using 4 X 4 matrix keypad.


Interfacing keypad

The rows are connected to an output port and the columns are connected to an input port.


To detect a pressed key, the microcontroller grounds all rows by providing 0 to the output latch, and then it reads the columns. If the data read from the columns is D3-D0=1111, no key has been pressed and the process continues until a key press is detected. However, if one of the column bits has a zero, this means that a key press has occurred. For example, if D3-D0=1101, this means that a key in the D1 column has been pressed.


After a key press is detected, the microcontroller will go through the process of identifying the key. Starting with the top row, the microcontroller grounds it by providing a low to row D0 only; then it reads the columns.


If the data read is all 1s, no key in that row is activated and the process is moved to the next row. It grounds the next row, reads the columns, and checks for any zero. This process continues until the row is identified. After identification of the row in which the key has been pressed, the next task is to find out which column the pressed key belongs to.


Interfacing keypad with ARM9_LPC2929

Now we want to scan a keypad in ARM9_LPC2929 Primer Board. In case of 4X4 matrix Keypad both the ends of switches are connected to the port pin i.e. four rows and four columns. So in all sixteen switches have been interfaced using just eight lines.


1Keypads arranged by matrix format, each row and column section pulled by high or low. All row lines(P0.0 – P0.3) and column lines (P1.0 to P1.3) connected directly by the port pins.


Note: While using Keypad ensures all slide switches (SW20-SW27) to no connection position because the same lines used for both slide switches and matrix keypads.


slide-switch 

Pin Assignment with ARM9_LPC2929

 

4x4 Matrix Lines

ARM9_LPC2929 Lines

4x4 Matrix Keypad

ROW

ROW-0

P0.0

 4x4-matrix-keypad-

ROW-1

P0.1

ROW-2

P0.2

ROW-4

P0.3

COLUMN

COLUMN-0

P1.0

COLUMN-1

P1.1

COLUMN-2

P1.2

COLUMN-3

P1.3

 

Circuit Diagram to Interface Keypad with ARM9_LPC2929



circuit-diagram-to-interface-keypad-with-arm9-lpc2929


C Program to 4 X 4 matrix keypad using ARM9_LPC2929

Title : Program to 4x4 Matrix keypad interfacing
#include 

#include 


#define RS 0x80000 // Register Select

#define RW 0x40000 // Read Write Select

#define EN 0x20000 // Enable

#define D7 0x08000 // Data Line 7

#define D6 0x04000 // Data Line 6

#define D5 0x02000 // Data Line 5

#define D4 0x01000 // Data Line 4


#define MAT_ROW 0xF

#define MAT_COL 0xF


void lcd_cmd (char);

void lcd_data (char);

void lcd_initialize (void);

void lcd_display (void);

void LCD4_Convert(char);

void delay(int);


char cmd[] = {0x33,0x32,0x28,0x0C,0x06,0x01}; // LCD Comments

char msg[] = {" MATRIX KEYPAD "}; // First Line of LCD

char msg1[] = {" PRESSED KEY : "}; // Second Line of LCD


char array[4][4] = {'C','D','E','F','8','9','A','B','4','5','6','7','0','1','2','3'}; // Char to Display

int a,b,Row,Col;

int main(void)


{

SFSP0_0 = 0xC;SFSP0_1 = 0xC;SFSP0_2 = 0xC;SFSP0_3 = 0xC;

SFSP1_0 = 0xC;SFSP1_1 = 0xC;SFSP1_2 = 0xC;SFSP1_3 = 0xC;

GPIO0_DR |= 0x000FF000;

lcd_initialize();

lcd_display();


while(1)

{

GPIO0_DR &= ~MAT_ROW; // Row set as Input

GPIO1_DR |= MAT_COL; // Col set as Output

GPIO1_OR &= ~MAT_COL; // Col set as Low

lcd_cmd(0xCF);

a = GPIO0_PINS; // Read Value of Row

a = a & 0xF;


switch(a)

{

case 0xE:

Row = 0;

GPIO1_OR |= MAT_COL; // Col set as High

GPIO0_DR |= MAT_ROW; GPIO1_DR &=~ MAT_COL; //Row set as Output & Col set as Input


GPIO0_OR &= ~MAT_ROW; // Row set as Low

b = GPIO1_PINS & 0xF; // Read Value of Col


switch(b)

{

case 0xE:

Col = 0;

lcd_data((array[Row][Col]));

break;


case 0xD:

Col = 1;

lcd_data((array[Row][Col]));

break;


case 0xB:

Col = 2;

lcd_data((array[Row][Col]));

break;


case 0x7:

Col = 3;

lcd_data((array[Row][Col]));

break;

}

break;

case 0xD:

Row = 1;

GPIO1_OR |= MAT_COL // Col set as High

GPIO0_DR |= MAT_ROW; GPIO1_DR &=~ MAT_COL;

GPIO0_OR &= ~MAT_ROW; // Row set as Low

b = GPIO1_PINS & 0xF; // Read Value of Col


switch(b)

{

case 0xE:

Col = 0;

lcd_data((array[Row][Col]));

break;


case 0xD:

Col = 1;

lcd_data((array[Row][Col]));

break;


case 0xB:

Col = 2;

lcd_data((array[Row][Col]));

break;


case 0x7:

Col = 3;

lcd_data((array[Row][Col]));

break;

} break;


case 0xB:

Row = 2;

GPIO1_OR |= MAT_COL; // Col set as High

GPIO0_DR |= MAT_ROW; GPIO1_DR &=~ MAT_COL;

GPIO0_OR &= ~MAT_ROW; // Row set as Low

b = GPIO1_PINS & 0xF; // Read Value of Col


switch(b)

{

case 0xE:

Col = 0;

lcd_data((array[Row][Col]));

break;


case 0xD:

Col = 1;

lcd_data((array[Row][Col]));

break;


case 0xB:

Col = 2;

lcd_data((array[Row][Col]));

break;


case 0x7:

Col = 3;

lcd_data((array[Row][Col]));

break;

}break;


case 0x7:

Row = 3;

GPIO1_OR |= MAT_COL; // Col set as High

GPIO0_DR |= MAT_ROW; GPIO1_DR &=~ MAT_COL; GPIO0_OR &= ~MAT_ROW; // Row set as Low

b = GPIO1_PINS & 0xF; // Read Value of Col


switch(b)

{

case 0xE:

Col = 0;

lcd_data((array[Row][Col]));

break;


case 0xD:

Col = 1;

lcd_data((array[Row][Col]));

break;


case 0xB:

Col = 2;

lcd_data((array[Row][Col]));

break;


case 0x7:

Col = 3;

lcd_data((array[Row][Col]));

break;

}break;


default:

break;

}

}

}


void delay(int n) // Delay function

{

unsigned int i,j;

for(i=0;i