Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

/* @file HelloKeypad.

pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates the simplest use of the matrix Keypad library.
|| #
*/
#include <Keypad.h>

const byte ROWS = 4; // Four rows


const byte COLS = 4; // columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPins[ROWS] = {A3,A2,A1,A0};// Connect keypad ROW0, ROW1, ROW2 and ROW3 to
these Arduino pins.
byte colPins[COLS] = {6,5,4,3};// Connect keypad COL0, COL1 and COL2 to these
Arduino pins.
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial.begin(9600);
}

void loop(){
char key = keypad.getKey();

if (key){
Serial.println(key);
}
}

You might also like