My final aim is to do an 8x8 keypad, presently I have 4x4 keypad available,so am trying out with that. Am using Arduino Uno R3 compatible. My setup is as in the attached: My problem is how to detect the column that went low on key press as to determined the key. Presently any key on Col 0 returns 240; Col1 returns 232; etc (dont know if that is ok. )Please help.

Many thanks for your time. I understand the point you raised, if you look through the code, the area I commented out, should handle that, but for now, the function is displaying it on the screen. The way it run now is that, it display (or returns) all the keys in the array, one after another even without any keypress. I believe there should be an if condition that will make the condition display (or return) ONLY the pressed key. The IF condition is what I think should solve my problem. Please help.

Ok, i made the corrections you pointed out, but here is what i don't understand, assuming :

incoming =240 (ie 11110000) and mask = 127(ie 01111111);...

byte Mymask[4] = { 0x7f,0xbf,0xdf,0xef };

Where did you get this from though? It isn't in your code.

You've got mask initially set to 0x80 hex, which is 128 decimal, not 127. And 128 decimal is 1000 0000 binary, not 0111 1111

At no point in your code does it equal 127 either.

So, I had to perform the inversion. There are many ways of achieving the desired outcome of course.

Now if you change the existing code in different ways (e.g. decide to set mask to 0x7f instead of 0x80) then other bits of code would need to change too, because your right-shift operation further down the code

(the line that is "mask = mask >> 1;") is not going to pad the left side of the bits in the mask with '1'. It will pad with zero.

The inversion operation that I did would have correctly handled the situation and did not require setting the mask to 0x7f.

Anyway, it really is up to you how you wish to achieve the result, there are many ways to skin the cat.

As a test I attached a led to Row0 /Col0 and when I pressed the corresponding key to Row0/Col0; the led turns up , but the IF condition at line 78 is not display(or returning) the corresponding keypad character (that is my problem). Can you please look at that IF condition again.

Many thanks shabaz, i was able to sort the issue out. I had to include a saperate Column masking and its working now. The only challange is that its not waiting for keypress. I want to open a new thread for that. Here is the working code for anyone that may need.

My final aim is to do an 8x8 keypad, presently I have 4x4 keypad available,so am trying out with that. Am using Arduino Uno R3 compatible. My setup is as in the attached: My problem is how to detect the column that went low on key press as to determined the key. Presently any key on Col 0 returns 240; Col1 returns 232; etc (dont know if that is ok. )Please help.