Diferencia entre revisiones de «Keypad»

De ArduWiki
Saltar a: navegación, buscar
(Referencias)
(Ejemplo 1)
Línea 68: Línea 68:
 
byte colPins[COLS] = {8, 7, 6};    //Pines para columnas
 
byte colPins[COLS] = {8, 7, 6};    //Pines para columnas
  
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
+
Keypad teclado = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
  
 
void setup(){
 
void setup(){
Línea 75: Línea 75:
 
    
 
    
 
void loop(){
 
void loop(){
   char key = keypad.getKey();  
+
   char key = teclado.getKey();  
 
   if (key){
 
   if (key){
 
     Serial.println(key);
 
     Serial.println(key);

Revisión del 18:46 7 oct 2019

Descripción

Un teclado matricial es un dispositivo que agrupa en filas y columnas (de alli el nombre matricial, 3x3, 3x4, 4x4) varios pulsadores y permite controlarlos usando un número de pines inferior al que necesitaríamos al usarlos de forma individual.

Tip: Al ser simples pulsadores actuaremos igual que con ellos, poniendo cada linea con un pull-up.


Sintaxis

#include <Keypad.h>

Parámetros

Métodos

Métodos disponibles librería Keypad.h
Método Descripción
getKey()
getKeys()
getState()
isPressed()
addEventListener()
keyStateChanged()
findKeyInList()
bitMap()
pin_mode()
pin_read()
pin_write
findKeyInList()
setDebounceTime()
setHoldTime()
waitForKey()

Comentarios

Advertencias

Ejemplo 1

#include <Keypad.h>

const byte ROWS = 4;    //filas
const byte COLS = 3;    //columnas
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //Pines para filas
byte colPins[COLS] = {8, 7, 6};    //Pines para columnas

Keypad teclado = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup(){
  Serial.begin(9600);
}
  
void loop(){
  char key = teclado.getKey(); 
  if (key){
    Serial.println(key);
  }
}

Vea también


Referencias