Interfacing with LCD and Keypad
Interfacing with LCD and Keypad
Hướng dẫn
Write C code to display letters on the LCD screen based on which a key of
4x4 keypad has been pressed. The schematic uses an atmega328p, a 4x4
keypad, and an LCD screen.
[See Videos]
1. https://www.youtube.com/watch?v=G3A3Tsr6eQE
2. https://www.youtube.com/watch?v=shQOflhze9Y
KEYS:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include "lcd.h" // Include LCD library (if you have one, or write your own)
#define ROWS 4
#define COLS 4
char keys[ROWS][COLS] = {
};
void keypad_init() {
KEYPAD_DDR = 0x0F; // Set the first 4 bits (rows) as outputs, the rest as
inputs (columns)
}
// Function to read the pressed key from the keypad
char keypad_get_key() {
int main(void) {
lcd_clear();
lcd_puts("Press a key:");
char key;
while (1) {
lcd_clear();
lcd_puts("Key: ");