If a Keypad sequence is entered then do something.

I am pretty new to Arduino and programming and I am trying to learn by doing. I am working on a project in which a scoreboard made of 4x 7 segment displays are controlled by a 4x4 keypad. I will attach a picture of the keypad below. I want the order of operations to be:

  1. Select team to apply score to (A or B)
  2. Enter number to add to score.
  3. Press either A or B again to confirm/send to scoreboard.
    I have the keypad setup using the keypad.h library. The 7 segments are controlled by a MAX7219. What would be the best way to achieve this?
    Any help would be appreciated, thanks!

Please do not double post your questions.

Show us what you have done so far.

Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:

Use CTRL T to format your code.
Attach your ‘complete’ sketch between code tags, use the </> icon in the posting menu.
[code]Paste your sketch here[/code]

Once you get the number you want displayed, just send it to the appropriate MAX7219 register, 1 to 8.

digitalWrite (ssPin, LOW);
SPI.transfer (registerNumber); // 1 to 8 for the displays
SPI.transfer(fontArray[numberToDisplay]); // 0 to 9, H, E, L, P, -  are available if using the built in decode.
digitalWrite (ssPin, HIGH);

Set up the 5 control registers in setup(). Read the datasheet, the data to send to them is pretty simple.
SCK, MOSI, SS connect to the MAX7219.
Don't forget 0.1uF and 10uF caps on the VCC pin.

this question seems very vague. we cant tell exactly what you want. I can only assume your small display is displaying a team score on each side? you should have some indication to the user that the button presses are recognized. maybe make the score flash when its selected to be changed? or if you intend to eventually do more then maybe navigate a simple menu on the display? does the score just count up when a button is pressed? what kind of score is this for? is there a score reached for a "win"?

where are you at in your project?
is the keyboard library working for you? are you able to display numbers yet?
are you able to get button pushes yet? are you using some matrix technique or library to get button pushes?
can you post the code you have that is doing that so far?

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() {
  keypad.addEventListener(keypadEvent); // Add an event listener for this keypad
  scoreA = 0;
  scoreB = 0;

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

  if (key) {

void keypadEvent(KeypadEvent key) {
  switch (key)  {
    case 'A':
      switch (key) {
        case '1':
          scoreA = scoreA + 1;
        case '2':
          scoreA = scoreA + 2;


//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!