/*
Hello!
You can check diagramplan.h to see the planned wiring diagram
for this project!
Have a nice day! ^^
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
// Initialize the LCD with I2C address 0x27
LiquidCrystal_I2C lcd(0x27, 20, 4); // 20 columns and 4 rows
// Keypad configuration
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns [Inaccurate to work]
char keys[ROWS][COLS] = {
{'1', '2', '3', ''},
{'4', '5', '6', ''},
{'7', '8', '9', ''},
{'%', '0', '*', ''}
};
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
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
String inputString = ""; // String to hold the typed characters
const int buzzerPin = 10; // Buzzer connected to digital pin 10
void setup() {
lcd.begin(20, 4); // Initialize the LCD with 20 columns and 4 rows
lcd.backlight(); // Turn on the LCD backlight
lcd.setCursor(0, 0); // Set cursor to the first row
lcd.println("1%");
delay(250); // Delay of 250ms
lcd.clear();
lcd.println("2%");
delay(250); // Delay of 250ms
lcd.clear();
lcd.println("3%");
delay(250); // Delay of 250ms
lcd.clear();
lcd.println("4%");
delay(250);
lcd.clear(); // Delay of 250ms
lcd.println("5%");
delay(500); // Delay of 500 ms
lcd.clear();
lcd.println("6%");
delay(250); // Delay of 250ms
lcd.clear();
lcd.println("7%");
delay(250); // Delay of 250ms
lcd.clear();
lcd.println("8%");
delay(250); // Delay of 250ms
lcd.clear();
lcd.println("9%");
delay(2000);
lcd.clear(); // Delay of 250ms
lcd.println("10%");
delay(250); // Delay of 250ms
lcd.clear();
lcd.println("Loaded libraries!");
lcd.setCursor(0, 1);
lcd.println("(10/10)");
delay(3000); // Wait for 3 seconds
lcd.clear(); // Clear the display
lcd.setCursor(0, 0); // Set cursor to the first row
lcd.print("Press a key:");
lcd.setCursor(0, 1); // Set cursor to the second row
pinMode(buzzerPin, OUTPUT); // Initialize the buzzer pin as an output
}
void loop() {
char key = keypad.getKey();
if (key) {
inputString += key; // Append the pressed key to the input string
lcd.clear(); // Clear the display
lcd.setCursor(0, 0);
lcd.print("Press a key:");
lcd.setCursor(0, 1);
lcd.print(inputString); // Print the input string on the LCD
tone(buzzerPin, 1000, 200); // Make a sound with the buzzer (frequency: 1000Hz, duration: 200ms)
}
}
Made from Indo