Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

4x4 Matrix Keypad and 16x2 LCD Menu System Sample (CY8CKIT-059)

Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted


In the following discussion, 


I was asked for a sample to emulate an Arduino sample below



Unlike the Arduino sample, I used a non-I2C LCD 1602A.

Also  I prepared a simple menu system which can be expanded later (hopefully) without modifying the main loop.

void do_menu_1(void) ;
void do_menu_2(void) ;
void do_menu_3(void) ;
void do_menu_4(void) ;

m_list_type menu[] = {
    { "MenuItem1", do_menu_1, "first menu"  },
    { "MenuItem2", do_menu_2, "second menu" },
    { "MenuItem3", do_menu_3, "third menu"  },
    { "MenuItem4", do_menu_4, "fouth menu"  }
} ;

int num_menu = sizeof(menu) / sizeof(m_list_type) ;
int current_menu_row = 0 ;
int active_menu_id = 0 ;
int menu_height   = 2 ;

For the operation, I mapped 

C: up

😧 down

#: select


Matrix Key Schematic


CharLCD Schematic


For the CharLCD (1602A), the only pin combination, I could find to be usable were P2[6:0] or P2[7:1].

And with this configuration, CY8CKIT-059's LED and push-SW won't be usable for other purpose.

And finally I noticed the A pin of 1602A can be used for backlight ... >_<

Anyway, here it is.



0 Replies