Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I’m fairly new to coding and was wondering if I could get some help. This is what I would like my code to do:

1. Have the question "what size?" displayed onto the lcd.
2. Then input size from keypad to lcd.
3. when ‘#’ is pressed, it should act as an enter key.
4. Also I would like "D" to be a clear key. So if the user makes a mistake while entering a size they will then press D to start over.

I am using the standard 16x2 LCD and the keypad size is 4x4.

What I have tried:

Here is what I have so far:
C++
#include <liquidcrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <keypad.h>

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

char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

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

//Create an object of keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Enter Size: ");
Serial.begin(9600);
}

void loop(){
char key = keypad.getKey();

// Print if key pressed
if (key){
Serial.println(key);
lcd.setCursor(0,1);

}
}
Posted
Updated 17-Jan-22 20:10pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900