LCD IC2 16x2 using 4x3 Keypad


I’m new to Arduino and this is my first attempt at a program.
The idea behind my project is to automate my kids wooden play
kitchen with a microwave that they can play with. I’ll attach
my code below. I know everybody says that there are plenty of
examples to learn off and use but i have tried a few and still can’t
get the 4x3 keypad to print to the LCD over serial.

Is there something i am missing or anything obvious i that you can
point out so that i can research or figure out on my own.

I’m not one of those people that want my program written out for me,
I am keen to learn.

Any help would be great!

Thanks in advance

Kitchen3.0.ino (3.59 KB)

You are not reading the keypad properly. Look at the CustomKeypad example in the Keypad library examples for code on how to read a character from the customKeypad object. It looks like this:

char customKey = customKeypad.getKey();

Your code will be seen by more members if you post it correctly per the guidelines in the “how to use this forum-please read” sticky topics. Like so:

#include <Key.h>
#include <Keypad.h>

|| Example sketch for the Addicore 4x3 matrix array 12
key membrane switch keypad,
|| found at:
|| After connecting your keypad to your Arduino (as detailed below) and uploading 
|| this sketch to your Arduino, you can then open the Serial Monitor on your
|| computer and ensure that the baud is set to 9600. Then press any of the buttons
|| on
the keypad to see the pressed button show up on the Serial Monitor.
|| Wire the keypad to your Arduino using information below: 
|| Note: Pins one and seven on the keypad are labeled with little embossed plastic 
||       numbers on the black connector
|| Wiring: 
||          Keypad 
> Arduino
||            1            3
||            2            4
||            3            5
||            4            6
||            5            7
||            6            8
||            7            9
Modified by Craig Thompson (, December 15, 2014
|| Based on CustomKeypad.pde by Alexander Brevig (
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3};    //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

/* Example Software Sketch
 16 character 2 line I2C Display
 Backpack Interface labelled "A0 A1 A2" at lower right.
 Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
 MOST use address 0x27, a FEW use 0x3F */

/*-----( Import needed libraries )-----*/
#include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here: 
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 16 chars 2 line display
// A FEW use address 0x3F
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

/*-----( Declare Variables )-----*/

void setup()   /*----( SETUP: RUNS ONCE )----*/
  Serial.begin(9600);  // Used to type in characters

  lcd.begin(16,2);   // initialize the lcd for 16 chars 2 lines, turn on backlight

//-------- Write characters on the display ------------------
// NOTE: Cursor Position: (CHAR, LINE) start at 0  
  lcd.setCursor(0,0); //Start at character 4 on line 0
  lcd.print("Angus and Jack's");
  lcd.print("Awesome Kitchen!");

// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
  lcd.setCursor(5,0); //Start at character 0 on line 0

}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/

  char=keypad   // not the right way to read keypad,  Use the getKey() method.

/* --(end main loop )-- */

/* ( THE END ) */