Date created: Monday, March 2, 2015 9:20:09 PM. Last modified: Monday, March 2, 2015 9:21:56 PM
4x4 Keypad
Membrane Keypad 4x4 Matrix
Arduino Pins | Keypad Pins
13 | 5
12 | 6
11 | 7
10 | 8
9 | 1
8 | 2
7 | 3
6 | 4
#include <Keypad.h> const byte ROWS = 4; // Four rows const byte COLS = 4; // Three 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] = { 9, 8, 7, 6 }; byte colPins[COLS] = { 13, 12, 11, 10 }; // Create the Keypad Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); void setup() { Serial.begin(9600); } void loop() { char key = kpd.getKey(); if(key) // Check for a valid key. { Serial.println(key); } }
Previous page: The Fat Controller
Next page: 4x4 Keypad I2C 8bit IO Expander