Advertisement
KingOfWesteros

Aula Síncrona 02

Apr 24th, 2021
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #include <Keypad.h>
  2. #include <LiquidCrystal.h>
  3.  
  4. //=========================================
  5. // Configurando LCD
  6. //=========================================
  7.  
  8. #define RS     12   // PINO DE CONFIGURAÇÃO
  9. #define ENABLE 11   // PINO DE CONFIGURAÇÃO
  10. #define D4     4    // PINO DE DADOS
  11. #define D5     5    // PINO DE DADOS
  12. #define D6     6    // PINO DE DADOS
  13. #define D7     7    // PINO DE DADOS
  14.  
  15. LiquidCrystal lcd(RS, ENABLE, D4,D5,D6,D7);
  16.  
  17. //=========================================
  18. // Configurando teclado
  19. //=========================================
  20.  
  21. const byte qtd_linhas  = 4;
  22. const byte qtd_colunas = 4;
  23.  
  24. char teclas[qtd_linhas][qtd_colunas] = {
  25.   {'1','2','3','A'},
  26.   {'4','5','6','B'},
  27.   {'7','8','9','C'},
  28.   {'*','0','#','D'}
  29. };
  30.  
  31. byte pinos_linhas[qtd_linhas]   = {0,1,2,3};
  32. byte pinos_colunas[qtd_colunas] = {A0,A1,A2,A3};
  33.  
  34. Keypad teclado = Keypad(makeKeymap(teclas),
  35.                pinos_linhas,
  36.                pinos_colunas,
  37.                qtd_linhas,
  38.                qtd_colunas);
  39.  
  40.  
  41. //=========================================
  42. // Configurações iniciais
  43. //=========================================
  44.  
  45. void setup()
  46. {  
  47.     // Configuração inicial do display
  48.     lcd.begin(16,2);
  49.     lcd.clear();
  50.     lcd.setCursor(0,0);    
  51. }
  52.  
  53.  
  54. //=========================================
  55. // Inicio do programa
  56. //=========================================
  57.  
  58. void loop()
  59. {
  60.   String tecla = "";
  61.  
  62.   // Escrevendo nome na tela
  63.   lcd.setCursor(0,0);
  64.   lcd.print("SEU NOME");
  65.    
  66.   // Captura do valor digitado
  67.   char valorDigitado = teclado.getKey();
  68.   if (valorDigitado != NO_KEY){
  69.     tecla = valorDigitado;
  70.  
  71.   // Exibir valor ditigado na 2ª linha
  72.     lcd.setCursor(0,1);
  73.     lcd.print(valorDigitado);
  74.     delay(10);
  75.   }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement