Advertisement
Ultizin

Grupo 3 | Projeto 5

Jun 17th, 2025
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <Keypad.h>
  2.  
  3. const byte qtdLinhas = 4;
  4. const byte qtdColunas = 4;
  5.  
  6. char matriz_teclas[qtdLinhas][qtdColunas] = {
  7.   {'1', '2', '3', 'A'},
  8.   {'4', '5', '6', 'B'},
  9.   {'7', '8', '9', 'C'},
  10.   {'*', '0', '#', 'D'}
  11. };
  12.  
  13. byte PinosqtdLinhas[qtdLinhas] = {9, 8, 7, 6};
  14. byte PinosqtdColunas[qtdColunas] = {5, 4, 3, 2};
  15.  
  16. Keypad meuteclado = Keypad(makeKeymap(matriz_teclas), PinosqtdLinhas, PinosqtdColunas, qtdLinhas, qtdColunas);
  17.  
  18. void setup() {
  19.   Serial.begin(9600);
  20.   Serial.println("Aperte uma tecla...\n");
  21. }
  22.  
  23. void loop() {
  24.   char tecla_pressionada = meuteclado.getKey();
  25.   if (tecla_pressionada) {
  26.     Serial.print("Tecla pressionada: ");
  27.     Serial.println(tecla_pressionada);
  28.   }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement