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:
#include <liquidcrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <keypad.h>
const byte ROWS = 4; const byte COLS = 4;
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}; byte colPins[COLS] = {5, 4, 3, 2};
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();
if (key){
Serial.println(key);
lcd.setCursor(0,1);
}
}