// 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.print(keypress); // Display value on Serial Monitor
while ((Keypad.Key_State())) {} // Stay here while Key is held down
}
}
With above code and diagram I tried it with UNO, MEGA and ESP32
It works well with UNO and MEGA but in case of ESP32 it displays wrong information like
For key D it shows 4
For key 4, 5 and 6 it shows 1
For 7 it shows 2
For 8 it shows A
For 9 it shows 3
Anything at anytime it is showing like that
Kindly help me in resolving such an issue
Thanks !!