You have no items in your shopping cart.

Subtotal: 0.00

How to Interface Keypad with CY8C3866 PSOC3 Development Board

PSoc 3 Development kit

The PSoc 3 Development 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 FX2LP Programmer which is done through USB port.

Cypress CY8C3866 core (CY8C3866), PSoc 3 Development kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers. It integrates on board CAPSENSE BUTTONS, CAPSENSE LINEAR SLIDER, UART, ADC, DAC, Relay, Buzzer, Seven Segment, Serial EEPROM, Temperature Sensor LM35, Matrix Keypad, Switch, LED, Stepper Motor Driver, Traffic Light Controller, RTC, LCD & GLCD Display to create a stand-alone versatile test platform. User can easily engage in Development in this platform, or use it as reference to application Development.

Keypad

A 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 CY8C3866

We now want to scan a keypad in CY8C3866 Development 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 by selection J5, all row lines(P3.4 – P3.7) and column lines(P3.0 to P3.3) connected directly by the port pins.

Pin Assignment with CY8C3866



 

4x4 Matrix Lines

CY8C3866 Lines

4x4 Matrix Keypad

ROW

ROW-0

P3.4

ROW-1

P3.5

ROW-2

P3.6

ROW-4

P3.7

COLUMN

COLUMN-0

P3.0

COLUMN-1

P3.1

COLUMN-2

P3.2

COLUMN-3

P3.3

 



Circuit Diagram to Interface Keypad with CY8C3866





C Program to 4 X 4 matrix keypad using CY8C3866

***************************************************************************************

Title : Program to keypad interfacing

***************************************************************************************

#include  uint8 row1,col1;

uint8 key_table[4][4]={3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12};

uint8 flag=1; uint8 Scan_Keypad(void);

void main()

{

LCD_Char_1_Start();

Interrupt_Start();

CyGlobalIntEnable;;

for(;;)

{

if(flag!=1)

{

LCD_Char_1_Position(0,0);

LCD_Char_1_PrintString("key pressed");

LCD_Char_1_Position(1,14);

LCD_Char_1_PrintInt8(key_table[row1][col1]);

/* Place your application code here. */

}

LCD_Char_1_Position(0,0);

LCD_Char_1_PrintString("key pressed");

LCD_Char_1_Position(1,0);

LCD_Char_1_PrintString("Press any key");

}

}

uint8 Scan_Keypad()

{

uint8 row,col,key; Matrix_Write(0xF0);

row=Matrix_Read();

//LCD_Char_1_Position(0,0);

//LCD_Char_1_PrintInt8(row);

Matrix_Write(0x0F);

col=Matrix_Read();

key=~(row|col);

return key;

}

/* [] END OF FILE */