Hi,
I'm using the D1 to display the keypad to lcd screen. I am having a problem with attaching the keypad to the board. The code below works just fine alone for the keypad and now I want to connect the lcd.
Since pin D1, D2 are reserved for SDA, SCL, I shift pins to this:
byte rowPins[ROWS] = {D8, D7, D6, D5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {D4, D3, D0};
(note: full working code is attached below)
Now the keypad stop working (key are not registered).
Suspected problem: according to the pinout (link attached) the D8 pin is "10k PULL_DOWN", but the Keypad library set all the pins to "INPUT_PULLUP". I am not very familiar with hardware so I need help to fix this problem please.
Keypad: standard 4x3 keypad with Keypad libraries downloaded from IDE
LCD: 16x2 i2c lcd
D1 board pins layout:
Codes:
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.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] = {D7, D6, D5, D4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {D3, D2, D1}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
LiquidCrystal_I2C lcd(0x27,16,2);
void setup(){
Serial.begin(115200);
Serial.println("STARTED:");
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(F("Password:"));
lcd.setCursor(1,0);
}
void loop(){
char key = keypad.getKey();
if (key){
lcd.clear();
lcd.setCursor(0,0);
Serial.println(key);
lcd.print(key);
}
}