Extension. . Perform a 4x4 keyboard decoder, rearrange the key values to get the
ID: 3882386 • Letter: E
Question
Extension. .
Perform a 4x4 keyboard decoder, rearrange the key values to get the
hexadecimal numbering and display the code in 4 LED's
Programation:
#include const byte Filas = 4; //Cuatro filas const byte Cols = 4; //Cuatro columnas byte Pins_Filas[] = {6, 7, 8, 9}; //Pines Arduino a los que contamos las filas. byte Pins_Cols[] = { 2, 3, 4, 5}; // Pines Arduino a los que contamos las columnas. char Teclas [ Filas ][ Cols ] = { {'1','2','3','A'}, {'4','5','6','B'}, {'7','8','9','C'}, {'*','0','#','D'} }; Keypad Teclado1 = Keypad(makeKeymap(Teclas), Pins_Filas, Pins_Cols, Filas, Cols); void setup(){ Serial.begin(9600); } void loop(){ char pulsacion = Teclado1.getKey() ; if (pulsacion != 0) // Si el valor es 0 es que no se ha pulsado ninguna tecla Serial.println(pulsacion); }
Explanation / Answer
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char CalculatorKeys[ROWS][COLS] = {
{'7','8','9','/'},
{'4','5','6','*'},
{'1','2','3','-'},
{'C','0','=','+'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad customKeypad = Keypad( makeKeymap(CalculatorKeys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey();
if (customKey){
Serial.println(customKey);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.