Skip to main content

amAm new at this but iI am working on a similar work, it is possible to use the pin 0 for your keypad, the pin is a RX pin by default making the pins(0,2,3,4,5,6,7).

asAs for the LCD iI would suggest you use an i2c backpack, it is a parallel to serial converter and means you would only need to use 2 pins (SDA, SCL which would be connected to pin A4, A5)

tryTry the code below for the keypad // (The code is if you have an i2c backpack

#include <Wire.h> #include <Keypad.h> //keypad library #include <LiquidCrystal_I2C.h> //library for the backpack

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

const byte ROWS = 4; //four rows const byte COLS = 3; //three columns

//define the Symbols on the buttons of the keypads char hexaKeys[COLS][ROWS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} };

byte rowPins[ROWS] = {0, 2, 3, 4}; //connect to the row pinouts of the keypad byte colPins[COLS] = {5, 6, 7, 8}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){ Serial.begin(9600); lcd.begin(16,2); for(int i = 0; i< 3; i++) { lcd.backlight(); delay(250); lcd.noBacklight(); delay(250); } lcd.backlight(); }

void loop(){

char customKey = customKeypad.getKey();

if (customKey){ lcd.print(customKey); } }

#include <Wire.h>
#include <Keypad.h> //keypad library
#include <LiquidCrystal_I2C.h> //library for the backpack

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns

//define the Symbols on the buttons of the keypads
  char hexaKeys[COLS][ROWS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

byte rowPins[ROWS] = {0, 2, 3, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 6, 7, 8}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup(){
  Serial.begin(9600);
  lcd.begin(16,2);
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();  delay(250);
    lcd.noBacklight();  delay(250);
  }
  lcd.backlight();
}
  
void loop(){
 
  char customKey = customKeypad.getKey();
  
  if (customKey){
    lcd.print(customKey);
  }
}

am new at this but i am working on a similar work, it is possible to use the pin 0 for your keypad, the pin is a RX pin by default making the pins(0,2,3,4,5,6,7).

as for the LCD i would suggest you use an i2c backpack, it is a parallel to serial converter and means you would only need to use 2 pins (SDA, SCL which would be connected to pin A4, A5)

try the code below for the keypad //The code is if you have an i2c backpack

#include <Wire.h> #include <Keypad.h> //keypad library #include <LiquidCrystal_I2C.h> //library for the backpack

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

const byte ROWS = 4; //four rows const byte COLS = 3; //three columns

//define the Symbols on the buttons of the keypads char hexaKeys[COLS][ROWS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} };

byte rowPins[ROWS] = {0, 2, 3, 4}; //connect to the row pinouts of the keypad byte colPins[COLS] = {5, 6, 7, 8}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){ Serial.begin(9600); lcd.begin(16,2); for(int i = 0; i< 3; i++) { lcd.backlight(); delay(250); lcd.noBacklight(); delay(250); } lcd.backlight(); }

void loop(){

char customKey = customKeypad.getKey();

if (customKey){ lcd.print(customKey); } }

Am new at this but I am working on a similar work, it is possible to use the pin 0 for your keypad, the pin is a RX pin by default making the pins(0,2,3,4,5,6,7).

As for the LCD I would suggest you use an i2c backpack, it is a parallel to serial converter and means you would only need to use 2 pins (SDA, SCL which would be connected to pin A4, A5)

Try the code below for the keypad (The code is if you have an i2c backpack)

#include <Wire.h>
#include <Keypad.h> //keypad library
#include <LiquidCrystal_I2C.h> //library for the backpack

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns

//define the Symbols on the buttons of the keypads
  char hexaKeys[COLS][ROWS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

byte rowPins[ROWS] = {0, 2, 3, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 6, 7, 8}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup(){
  Serial.begin(9600);
  lcd.begin(16,2);
  for(int i = 0; i< 3; i++)
  {
    lcd.backlight();  delay(250);
    lcd.noBacklight();  delay(250);
  }
  lcd.backlight();
}
  
void loop(){
 
  char customKey = customKeypad.getKey();
  
  if (customKey){
    lcd.print(customKey);
  }
}
Source Link
Tolu
  • 1
  • 3

am new at this but i am working on a similar work, it is possible to use the pin 0 for your keypad, the pin is a RX pin by default making the pins(0,2,3,4,5,6,7).

as for the LCD i would suggest you use an i2c backpack, it is a parallel to serial converter and means you would only need to use 2 pins (SDA, SCL which would be connected to pin A4, A5)

try the code below for the keypad //The code is if you have an i2c backpack

#include <Wire.h> #include <Keypad.h> //keypad library #include <LiquidCrystal_I2C.h> //library for the backpack

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

const byte ROWS = 4; //four rows const byte COLS = 3; //three columns

//define the Symbols on the buttons of the keypads char hexaKeys[COLS][ROWS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} };

byte rowPins[ROWS] = {0, 2, 3, 4}; //connect to the row pinouts of the keypad byte colPins[COLS] = {5, 6, 7, 8}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){ Serial.begin(9600); lcd.begin(16,2); for(int i = 0; i< 3; i++) { lcd.backlight(); delay(250); lcd.noBacklight(); delay(250); } lcd.backlight(); }

void loop(){

char customKey = customKeypad.getKey();

if (customKey){ lcd.print(customKey); } }