This circuit integrates a Membrane Matrix Keypad with an Arduino UNO microcontroller. The purpose of the circuit is to detect and process keypress events from the keypad and output the state of the keypresses to the Serial Monitor. The Arduino UNO is programmed to read inputs from the keypad, determine if a key has been pressed or released, and then print the corresponding key state to the Serial Monitor at a baud rate of 9600.
The following code is written for the Arduino UNO to interface with the Membrane Matrix Keypad:
/**
* This example shows how to read and print out the keypress state of the
* Adafruit 3x4 membrane matrix keypad.
*
* - Make sure to first install the following libraries through the Arduino Library Manager:
* - Adafruit Keypad (by Adafruit)
* - To view the keypress state, open the Serial Monitor inside the Arduino IDE
* and make sure baud rate is 9600.
*
* This example was originally written by Adafruit Industries.
*/
// Use this example with the Adafruit Keypad products.
// You'll need to know the Product ID for your keypad.
// Here's a summary:
// * PID3844 4x4 Matrix Keypad
// * PID3845 3x4 Matrix Keypad
// * PID1824 3x4 Phone-style Matrix Keypad
// * PID1332 Membrane 1x4 Keypad
// * PID419 Membrane 3x4 Matrix Keypad
#include "Adafruit_Keypad.h"
// define your specific keypad here via PID
#define KEYPAD_PID419
// define your pins here
// can ignore ones that don't apply
#define R1 2
#define R2 3
#define R3 4
#define R4 5
#define C1 8
#define C2 9
#define C3 10
#define C4 11
// leave this import after the above configuration
#include "keypad_config.h"
//initialize an instance of class NewKeypad
Adafruit_Keypad customKeypad = Adafruit_Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
customKeypad.begin();
}
void loop() {
// put your main code here, to run repeatedly:
customKeypad.tick();
while(customKeypad.available()){
keypadEvent e = customKeypad.read();
Serial.print((char)e.bit.KEY);
if(e.bit.EVENT == KEY_JUST_PRESSED) Serial.println(" pressed");
else if(e.bit.EVENT == KEY_JUST_RELEASED) Serial.println(" released");
}
delay(10);
}
This code is designed to be uploaded to the Arduino UNO microcontroller. It utilizes the Adafruit Keypad library to manage the keypad states and outputs the keypress information to the Serial Monitor. The pins defined in the code correspond to the wiring details provided in the previous section.