I am currently just working on getting the scores to be adjusted by using the sequence of selecting the team (A or B), choosing how much to add, then pressing the same team again to act as an enter key.
I am using a 4x4 keypad:
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
I already have it setup using the Keypad.h library. I can tell which key is pressed through a basic program that writes the key that is pressed to the serial monitor so I know that it is setup correctly. I am just hoping to be able to select either team A or B by pressing either A or B, then entering the number of points to be added to that team, and finally pressing the same team letter again to act as an enter key. I currently have only a rough draft of just playing around with some things and testing them out.
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int scoreA;
int scoreB;
void setup() {
Serial.begin(9600);
keypad.addEventListener(keypadEvent); // Add an event listener for this keypad
scoreA = 0;
scoreB = 0;
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.println(scoreA);
Serial.println(scoreB);
}
}
void keypadEvent(KeypadEvent key) {
switch (key) {
case 'A':
switch (key) {
case '1':
scoreA = scoreA + 1;
break;
case '2':
scoreA = scoreA + 2;
break;
}
break;
}
}
//I want to be able to choose the team (A or B), then the points to be added to that team, then reselect the team button to apple the change.
Like I said, it is a very rough beginning but we are getting there. I am using both an off brand Nano and an Arduino Uno but both are working perfectly. Also there is no need to worry about the only going positive. Thank you though!
Thank you so much for any help, I really appreciate it!
