/*
Código demonstrativo para a aula de Sistemas Embarcados,
Curso de Ciência da Computação e Engenharia da Computação
EEP.
*/
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20, 16, 2);
const byte LINHAS = 4;
const byte COLUNAS = 4;
char LayoutTeclas[LINHAS][COLUNAS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
//connect to the row pinouts of the keypad
byte PinosLinha[LINHAS] = {19, 18, 5, 17};
//connect to the column pinouts of the keypad
byte PinosColuna[COLUNAS] = {16, 4, 2, 15};
Keypad teclado = Keypad( makeKeymap(LayoutTeclas), PinosLinha, PinosColuna, LINHAS, COLUNAS );
void setup() {
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Escola de Eng. ");
lcd.setCursor(0, 1);
lcd.print(" de Piracicaba ");
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Sistemas ");
lcd.setCursor(0, 1);
lcd.print(" Embarcados ");
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("# Pressione a #");
lcd.setCursor(0, 1);
lcd.print("# Tecla #");
}
void loop() {
char tecla = teclado.getKey();
if (tecla) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("# Tecla: ");
lcd.setCursor(11, 0);
lcd.print(tecla);
lcd.setCursor(15, 0);
lcd.print("#");
lcd.setCursor(0, 1);
lcd.print("# ------------ #");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("# Pressione a #");
lcd.setCursor(0, 1);
lcd.print("# Tecla #");
}
}