One Wire KeyPad 4x4 Issues with sequence of keys

Arduino UNO in use
Connecting a single wire to A0 input to make working of keypad as a single IN

Here is the diagram

&

With this code below :

// Armuino --- Reading Membrane Keypad to Arduino with a Single Analog Wire  ---
// Video - https://www.youtube.com/watch?v=N39EXI_F8uA

#include "OnewireKeypad.h" // OneWireKeypad Library

char KEYS[] =   // Define keys' values of Keypad
{
	'1', '2', '3', 'A',
	'4', '5', '6', 'B',
	'7', '8', '9', 'C',
	'*', '0', '#', 'D'
};

/* Define Library :
OnewireKeypad <Print, #of buttons>
Keypad(Serial, Char values, #Rows, #Cols, Arduino Pin, Row_resistor, Columns_resistor) */
OnewireKeypad <Print, 16 > Keypad(Serial, KEYS, 4, 4, A0, 4700, 1000);

void setup ()
{
	Serial.begin(9600);
}

void loop()
{
	Keypad.SetHoldTime(100);  // Key held time in ms
	Keypad.SetDebounceTime(50); // Key Debounce time in ms
  
	if ((Keypad.Key_State() == 3))    // not pressed = 0, pressed = 1, released = 2,  held = 3
	{
		char keypress = Keypad.Getkey();  // put value of key pressed in variable 'keypress'
		Serial.print("Keypad Key: ");
		Serial.println(keypress);  // Display value on Serial Monitor
		while ((Keypad.Key_State())) {} // Stay here while Key is held down
	}
}

I am getting output like :

On serial monitor

Pressing Key 1 shows A
Pressing Key 2 shows 3
Pressing Key 3 shows 2
Pressing Key A shows

What are you expecting? Are the resistances correct? Are the wires correct?

Reference only the sketch and diagram from Post #1.

Ya I checked with everything and in fact I am on it replacing cables one by one but same result
And also, the lower of keypad means * 0 # not working

Resistance OK
Wires OK

If you tell OnewireKeypad.h you have 4x4, it expects 4x4... maybe your resistors or wiring is wrong.

I see

OK le me check with that thing fully again from very begining

Looks like you have the column pins reversed, although I would then expect Key A to show up as 1.

Mmm Ya something like that happened

So what to do now in that case

That would be 1 = A, 2 = B... and the bottom row is inop.

Stone soup.

That would be rows and colums swapped.
If the column pins are reversed, each row would go from right to left (A 3 2 1) instead of left to right (1 2 3 A). Not sure why the bottom row does not register at all.

Presumably the breadboard does not have the split power/ground rail in the middle, that would really throw things off.

1 Like

Ah. Got it now.

Makes me happy to see people are still using my library after all this time. :face_holding_back_tears:

1 Like

Done with that

Its working by reversing it all the way

reversing of pins and also the positions mutually executes everything out

O really that is yours :open_mouth:

:love_you_gesture: :v: :+1: :clap:

Old is Gold and Gold is used a protective layer on Satellites

Sometimes after all those Up gradations today, we at some moment realize that old versions were much better

"Voyager 1 and 2 from 70s"

You know while using ESP series with less number of pins these kinds of libraries are useful.

So many such past libraries are still on run with my experiments !!!!!!!!!!!!
(Not only in Electronics)

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.