This circuit involves an Arduino UNO microcontroller interfaced with a 4x4 Keypad and a 16x2 I2C LCD. The keypad is used to input characters, which are then displayed on the LCD. The keypad is connected to the digital pins D2 to D9 of the Arduino UNO, while the LCD is connected via the I2C interface (SDA and SCL pins).
4x4 Keypad (Simulator)
Arduino UNO
16x2 I2C LCD
/*
* This Arduino sketch reads input from a 4x4 keypad and displays the
* corresponding characters on a 16x2 I2C LCD. The keypad is connected to
* digital pins D2 to D9 of the Arduino UNO, and the LCD is connected via
* the I2C interface (SDA and SCL pins).
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
// Initialize the LCD with I2C address 0x27 and 16x2 display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Define the rows and columns for the keypad
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
// Define the keymap
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
// Connect keypad rows and columns to Arduino pins
byte rowPins[ROWS] = {2, 3, 4, 5}; // Connect to the row pinouts of the keypad
byte colPins[COLS] = {6, 7, 8, 9}; // Connect to the column pinouts of the keypad
// Create the Keypad object
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
// Initialize the LCD
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("You Entered ");
}
void loop() {
// Get the key pressed
char key = keypad.getKey();
// If a key is pressed, display it on the LCD
if (key) {
lcd.setCursor(0, 1); // Move cursor to the second line
lcd.print(key);
}
}
The example is a numeric keypad connected to the Arduino Uno and the Uno connected to an I2C LCD to display what is typed on the keypad.