/*
* This ESP32 code is created by esp32io.com
*
* This ESP32 code is released in the public domain
*
* For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-keypad-lcd
*/
/*#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#define ROW_NUM 4 // four rows
#define COLUMN_NUM 4 // four columns
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2','3', 'A'},
{'4','5','6', 'B'},
{'7','8','9', 'C'},
{'*','0','#', 'D'}
};
byte pin_rows[ROW_NUM] = {19, 18, 5, 12}; // GIOP19, GIOP18, GIOP5, GIOP17 connect to the row pins
byte pin_column[COLUMN_NUM] = {4, 2, 15, 14}; // GIOP16, GIOP4, GIOP0, GIOP2 connect to the column pins
Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows
int cursorColumn = 0;
int inputCount = 0;
String userInput1 = "";
String userInput2 = "";
String userInput3 = "";
void setup(){
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Enter input 1:");
}
void loop(){
char key = keypad.getKey();
if (key != NO_KEY) {
// Handle input 1
if (inputCount == 0) {
// Update the user input
userInput1 += key;
// Display the user input on the LCD
lcd.setCursor(0, 1);
lcd.print(userInput1);
// Check if input 1 is complete
if (userInput1.length() == 1) {
// Update the input count and prompt for input 2
delay(2000);
inputCount++;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Enter input 2:");
}
}
// Handle input 2
else if (inputCount == 1) {
// Update the user input
userInput2 += key;
// Display the user input on the LCD
lcd.setCursor(0, 1);
lcd.print(userInput2);
// Check if input 2 is complete
if (userInput2.length() >0 && key == '#') {
// Update the input count and prompt for input 3
inputCount++;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Enter input 3:");
}
}
// Handle input 3
else if (inputCount == 2) {
// Update the user input
userInput3 += key;
// Display the user input on the LCD
lcd.setCursor(0, 1);
lcd.print(userInput3);
// Check if input 3 is complete
if (userInput3.length() >0 && key == '#') {
// Update the input count and prompt for input 3
inputCount++;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Enjoy Prayushi");
}
}
}
if (key == '*'){ // if * is pressed anytime in between, it will reset the ESP32
ESP.restart();
}
}
*/
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#define ROW_NUM 4 // four rows
#define COLUMN_NUM 4 // four columns
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2','3', 'A'},
{'4','5','6', 'B'},
{'7','8','9', 'C'},
{'*','0','#', 'D'}
};
byte pin_rows[ROW_NUM] = {19, 18, 5, 12}; // GIOP19, GIOP18, GIOP5, GIOP17 connect to the row pins
byte pin_column[COLUMN_NUM] = {4, 2, 15, 14}; // GIOP16, GIOP4, GIOP0, GIOP2 connect to the column pins
Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2 rows
int cursorColumn = 0;
int inputCount = 0;
String userInput1 = "";
String userInput2 = "";
String userInput3 = "";
void setup(){
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Enter input 1:");
}
void loop(){
char key = keypad.getKey();
if (key != NO_KEY) {
// Handle input 1
if (inputCount == 0) {
// Update the user input
userInput1 += key;
// Display the user input on the LCD
lcd.setCursor(0, 1);
lcd.print(userInput1);
// Check if input 1 is complete
if (userInput1.length() == 1 && key == '#') {
// Update the input count and prompt for input 2
delay(2000);
inputCount++;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Enter input 2:");
}
}
// Handle input 2
else if (inputCount == 1) {
// Update the user input
userInput2 += key;
// Display the user input on the LCD
lcd.setCursor(0, 1);
lcd.print(userInput2);
// Check if input 2 is complete
if (userInput2.length() >0 && key == '#') {
// Update the input count and prompt for input 3
inputCount++;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Enter input 3:");
}
}
// Handle input 3
else if (inputCount == 2) {
// Update the user input
userInput3 += key;
// Display the user input on the LCD
lcd.setCursor(0, 1);
lcd.print(userInput3);
// Check if input 3 is complete
if (userInput3.length() >0 && key == '#') {
// Update the input count and prompt for input 3
inputCount++;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Enjoy Prayushi");
}
}
}
if (key == '*'){
ESP.restart();
}
}
//enjoy and good night :)