Hey everyone,
I want to thank the people that take their time help me out with my issue. I have a 4x4 button matrix hooked up and I want to make it output strings instead of characters. My first question is, is this possible and is there any existing code that will help me out?
My second question is, would it be possible to store an output of the button matrix to be then printed out when a simple button is pressed.
So it would go, a button on the button matrix is pressed the output is stored as a variable. Then when the simple button is pressed the output would be printed. This is what I have so far.
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
const char key[ROWS][COLS] = {
{"ELUM AO","ROMU MFR","LOMA6 BHS","LOJA JHS"},
{"ALPE4 GM","CEOR7 OBS","MIVI JSG","EUFO5 WC"},
{"EUAL13 WBB","PYCA80 CP","DIOP CY","SL "},
{" TOH","Other 1","Other 2","Other 3"}
};
byte rowPins[ROWS] = {4, 5, 6, 7}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {11, 10, 9, 8}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(key), rowPins, colPins, ROWS, COLS );
const int buttonPin = 12;
int ledPin = 13;
int buttonState = 0;
void setup(){
Serial.begin(9600);
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop(){
buttonState = digitalRead(buttonPin);
const char key = keypad.getKey();
if (buttonState == LOW){
digitalWrite(ledPin, LOW);
}
if (buttonState == HIGH){
digitalWrite(ledPin, HIGH);
Serial.println(key);
return;
}
}
I'm a newbie so as much explanation as you have time for would be appreciated. Thanks!