> Hi to all engineers, > > I am working on keypad routine that I ended up whole bunch of if's > and I was wondering if it is ok to use it like that. Hi Andre, I have always used a method that scans the keyboard and returns a number. Here's a snippet from my LCD terminal code at: http://bobblick.com/techref/projects/lcdterm/lcdterm.html Note I used Hitech C. I hope this doesn't wordwrap - it looks terrible on my terminal here. Cheerful regards, Bob byte scankb(void) { byte delay; byte key = 0; // first key returns 0, no key returns KB_NO_KEY byte column = 0b00001000; //RB3 is starting column. //if you reduce columncount it will sequence through fewer columns - ending earlier, //or starting later if you choose a different start column byte columncount = 6; // one more than the number of columns while(--columncount) { PORTB &= 0b00000111; PORTB |= column; //energize column but leave low 3 pins untouched for (delay = 10; --delay;); //this delay rejects key capacitance //test each row in sequence if(RA0) break; key++; //if you don't use all rows just remove if(RA1) break; key++; //or comment out ones you don't need if(RA2) break; key++; if(RA3) break; key++; column <<= 1; //shift to left, energize next column } return key; } -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist