/*
Código demonstrativo para a aula de Bancos de Dados aplicados à Internet das Coisas,
Curso de Engenharia e Administração de Sistemas de Banco de Dados,
Faculdade de Tecnologia - UNICAMP.
*/
#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("Fac. Tecnologia");
lcd.setCursor(0, 1);
lcd.print("Unicamp Limeira");
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Bancos de Dados ");
lcd.setCursor(0, 1);
lcd.print("Aplicados a IoT ");
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 #");
}
}