Arduino UNO R4 - Keypad - LCD
This tutorial instructs you how to program Arduino UNO R4 to read key pressed from a keypad and display it on LCD display.
Hardware Preparation
Or you can buy the following sensor kits:
1 | × | DIYables Sensor Kit (30 sensors/displays) | |
1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables.
Overview of Keypad and LCD
If you're unfamiliar with keypads and LCDs, including their pinouts, functionality, and programming, please refer to the following tutorials to learn more:
Wiring Diagram
This image is created using Fritzing. Click to enlarge image
Arduino UNO R4 Code
※ NOTE THAT:
The I2C address for the LCD might change depending on the maker. In our program, we used the address 0x27 as given by the manufacturer DIYables.
Detailed Instructions
Follow these instructions step by step:
- If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
- Connect the Arduino Uno R4 board to the keypad and LCD I2C according to the provided diagram.
- Connect the Arduino Uno R4 board to your computer using a USB cable.
- Launch the Arduino IDE on your computer.
- Select the appropriate Arduino Uno R4 board (e.g., Arduino Uno R4 WiFi) and COM port.
- Click on the Libraries icon on the left side of the Arduino IDE.
- Type DIYables_Keypad in the search box, and look for the keypad library by DIYables.io.
- Click the Install button to add the keypad library to your IDE.
- Search for "LiquidCrystal I2C" and look for the LiquidCrystal_I2C library by Frank de Brabander.
- Click the Install button to install the LiquidCrystal_I2C library.
- Copy the code and open it in the Arduino IDE.
- Click the Upload button in the Arduino IDE to upload the code to the Arduino UNO R4.
- Press keys on the keypad
- Check the LCD to see the result
If the LCD screen shows nothing, check Troubleshooting for LCD I2C for help.
Code Explanation
Check the explanations in the comments within the source code!