okk i have a serious problem with this SPirit Board. i m trying to Interface a Keypad which is included on the board, its a 4x4 keypad with a resistor array to which Vcc is connected. ok so here is the problem i m trying to check if any key is pressed but it dosnt wana coperate
this is my code
#include<lpc21xx.h> #include<lcd.h> #include<keypad.h> typedef int int32; int32 value; int main(void) { PINSEL2=0x00000000; //mode of operation PINSEL0=0x00000000; //mode of operation IODIR0 |= 0x0000183C; make_out_lcd_port(); lcd_init(); clr_lcd_port();delay(); lcd_cmd(0x00800000); delay(); clr_lcd_port(); lcd_data('G'); delay(); clr_lcd_port(); IODIR0 |= 0x0000183C; while(1) { value=IOPIN0; delay();delay();delay();delay(); value=value>>6; if(value==0xF) { lcd_cmd(0x00800000);delay();clr_lcd_port(); lcd_data('M');delay();clr_lcd_port(); } if(value!=0xf) { lcd_cmd(0x00800000);delay();clr_lcd_port(); lcd_data('X');delay();clr_lcd_port(); } } return 0; }
the LCD is working without any problem ok what i wanna do here is when no key is pressed show M and when a Key gets pressed show me X. it says X all the time weather a key is pressed or not :(
anyways Keypad is connected from Po.2 to P0.9 0.2 is RoW1 0.3 is RoW2 0.4 is RoW3 0.5 is RoW4 0.6 is CoL1 0.7 is CoL2 0.8 is CoL3 0.9 is CoL4
0.28 is RS of LCD 0.29 is EN of LCD
Any help will will appreciated :)
So did you do the standard debugging steps?
Just read your ports, and presenting what they see, while you press buttons? Just so you know you do get the stimuli you think you get - before you try to write a complete program to scan the keyboard?
By the way - a row/column keyboard isn't read by just making a single read. You either walk columns or rows while performing the scanning.