Problem with nodemcu 3.0 esp8266 and keypad 3x4

Hello.

I have a problem with my nodemcu 3.0 esp8266 and my keypad. For some reason, the last cable does not work. 3 and # are incorrect, and the 3 blocks the whole pressing unless I press 1 or 2 again.
1

2

1

2

4

5

6

7

7

8

9

0

3 and # are also mixed with 1 and *

/* @file HelloKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates the simplest use of the matrix Keypad library.
|| #
*/
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

byte rowPins[ROWS] = {D0, D3, D4, D5};  // ESP8266 pins connect to the row pins
byte colPins[COLS] = {D6, D7, D8}; // ESP8266 pins connect to the column pins


Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
}
  
void loop(){
  char key = keypad.getKey();
  
  if (key){
    Serial.println(key);
  }
}

The keypad is Whadda WPI300

R1 connects to D0,
R2 connects to D3
R3 connects to D4
R4 connects to D5
C1 connects to D6
C2 connects to D7
C3 connects to D8

One thing I noticed is that always the last cable does not work properly. If I put C3 on C2, the last cable is C2 in D8 doesn't work. I also can switch around the pin from D8 to S2 and will work and have the same issue. I tried manually to put the GPIO pins and still the same issue.

You can't use all IO-pins for all purposes.
Read this tutorial to understand what IO-pins to choose

Thanks. I used D2 and it works. I want to connect a I2C LCD to this, so I don't have more pins left. Looks like I also can't use S3/S2.

What are my options here? Can I use a port expander to increase the IO pins?

Yes sure you can. I suggest a SX1509 because this IO-expander has a onboard keyboard engine. This means all the details about switching HIGH/LOW for scanning the keyboard is done chip-internally.

best regards Stefan

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