Hi following is the routine i found at net for 4x4 matrix keypad in C.
www.8051projects.net/.../8051-programming.php
can i use this to display digits using the keypad inputs or do i need any keypad numabers matrix to be assigned?. If yes, Can sombody reply me the simple main code[while(1)] to monitor the key lets say if 5 is pressed then make P1 as high or something like that?. I just want to display digit 5 using keypad.
Thanks in advance.
It is often better to use space instead of tab for indenting the code. With spaces, the indent will be consistent when switching between editors or when presenting the code on the net.
Another thing. For an 8-bit processor, the code will be smaller and faster if you use 8-bit variables whenever you can, instead of using the 16-bit int data type.
Don't retype source code when making posts. Always copy/paste, to make sure you don't introduce errors. In C, the keyword is "if", and not "If".
In C, a function that doesn't take parameters should be specified with "void" instead of an empty list between the parentheses.
int main(void){ unsigned char key; key_init(); while (1) { key = get_key(); if (key == 5) { P1 = 0xFF; } if (key == 6) { P1 = 0; } } return 0; }
I would simply recommend that you always use spaces for indenting code - never use TABs!
The interpretation of TABs is entirely undefined - even different users of the same application may see different results due to different user settings!
The only thing you can be certain of with TABs is that they will not give reliable results!
Thanks for your kind guidance, Since i am in learning phase, i am making many mistakes. Will try to rectify it through experience.
I made the program as u said, It was working great. So i got excited, Your coding style is really good, Will follow it in future.
Thanks.