Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Keypad.h>
- #include <LiquidCrystal.h>
- //=========================================
- // Configurando LCD
- //=========================================
- #define RS 12 // PINO DE CONFIGURAÇÃO
- #define ENABLE 11 // PINO DE CONFIGURAÇÃO
- #define D4 4 // PINO DE DADOS
- #define D5 5 // PINO DE DADOS
- #define D6 6 // PINO DE DADOS
- #define D7 7 // PINO DE DADOS
- LiquidCrystal lcd(RS, ENABLE, D4,D5,D6,D7);
- //=========================================
- // Configurando teclado
- //=========================================
- const byte qtd_linhas = 4;
- const byte qtd_colunas = 4;
- char teclas[qtd_linhas][qtd_colunas] = {
- {'1','2','3','A'},
- {'4','5','6','B'},
- {'7','8','9','C'},
- {'*','0','#','D'}
- };
- byte pinos_linhas[qtd_linhas] = {0,1,2,3};
- byte pinos_colunas[qtd_colunas] = {A0,A1,A2,A3};
- Keypad teclado = Keypad(makeKeymap(teclas),
- pinos_linhas,
- pinos_colunas,
- qtd_linhas,
- qtd_colunas);
- //=========================================
- // Configurações iniciais
- //=========================================
- void setup()
- {
- // Configuração inicial do display
- lcd.begin(16,2);
- lcd.clear();
- lcd.setCursor(0,0);
- }
- //=========================================
- // Inicio do programa
- //=========================================
- void loop()
- {
- String tecla = "";
- // Escrevendo nome na tela
- lcd.setCursor(0,0);
- lcd.print("SEU NOME");
- // Captura do valor digitado
- char valorDigitado = teclado.getKey();
- if (valorDigitado != NO_KEY){
- tecla = valorDigitado;
- // Exibir valor ditigado na 2ª linha
- lcd.setCursor(0,1);
- lcd.print(valorDigitado);
- delay(10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement