Write stored two digit number to two 7 segment displays using Max7219 chip

Hello, I have a scoreboard code that I have almost up and running, the small missing factor is that i cant figure out how to get the scores which are stored in variables to be displayed on the 7 segment displays. For example, if I have 24 stored under scoreA, I want the left digit for team A to display 2 and the right one to display 4. And the same thing for team B. I am unsure how to split the stored 24 into the two parts 2 and 4 in order to send them to their respective displays.

#include "LedControl.h"  // Library used for communication with 7 segment

LedControl lc = LedControl(11, 12, 10, 1); //  (DIN, CLK, LOAD, number of Max7219 chips)

#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;                                        // Team A
int scoreB;                                        // Team B
int scoreAdd = 0;                                  // Hold the number that will be added to the team and the number that will be subtracted from current score if over 21
int value = 0;                                     // the number accumulator
int key;                                           // the key press
int isnum;
bool twentyOne;
bool powerOn;
/*int displayone = 0;
  int displaytwo = 0;


  // Variables to split whole number into single digits
  int rightdigit;
  int leftdigit;
*/
void(* resetFunc) (void) = 0;

void setup() {
  Serial.begin(9600);

  scoreA = 0;
  scoreB = 0;
  scoreAdd = 0;
  powerOn = true;
  twentyOne = true;

  lc.shutdown(0, false);                            // Wake up MAX7219
  lc.setIntensity (0, 15);
  // Put zeros on both displays at startup
  lc.setDigit(0, 0, 0, false);                    // (Max7219 chip #, Digit, value, DP on or off)
  lc.setDigit(0, 1, 0, false);

  lc.setDigit(0, 2, 0, false);
  lc.setDigit(0, 3, 0, false);

  lc.setDigit(0, 5, 0, false);                    // 21 Rules Indicator LED
  lc.setDigit(0, 7, 0, false);                    // 1 or 2/3 Games Indicator LED
}

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

  do
  {
    key = keypad.getKey();                          // input the key
    isnum = (key >= '0' && key <= '9');             // is it a digit?
    if (isnum)
    {
      scoreAdd = scoreAdd * 10 + key - '0';         // accumulate the input number
    }

  }
  while (isnum || !key);                          // until not a digit or while no key pressed

  if (key != NO_KEY) {
    if (key == 'A') {
      scoreA += scoreAdd;
      if (twentyOne == true) {
        if (scoreA > 21) {
          scoreAdd -= (21 - scoreA);
          scoreA -= scoreAdd;
        }
      }

      Serial.print("Team A: "); Serial.println(scoreA);
      Serial.print("Team B: "); Serial.println(scoreB);
    }
    if (key == 'B') {
      scoreB += scoreAdd;
      if (twentyOne == true) {
        if (scoreB > 21) {
          scoreAdd -= (21 - scoreB);
          scoreB -= scoreAdd;
        }
      }
      Serial.print("Team A: "); Serial.println(scoreA);
      Serial.print("Team B: "); Serial.println(scoreB);
    }
    /*if (key == '*') {
      if (powerOn == true) {
        LedControl lc = LedControl(11, 12, 10, 0);
        powerOn = false;
      }
      if (powerOn == false) {
        LedControl lc = LedControl(11, 12, 10, 1);
        powerOn = true;
      }
      }*/
    if (key == 'D') {
      twentyOne = !twentyOne;
      delay(100);
      Serial.print("Team A: "); Serial.println(scoreA);
      Serial.print("Team B: "); Serial.println(scoreB);
    }
    if (key == '#') {
      resetFunc();
      delay(1000);
      Serial.print("Team A: "); Serial.println(scoreA);
      Serial.print("Team B: "); Serial.println(scoreB);
    }
  }
  scoreAdd = 0;

}

Thanks for any help!! Really appreciate it.

Jamescross449:
... I am unsure how to split the stored 24 into the two parts 2 and 4 in order to send them to their respective displays.

you could use the 'divide' and 'mod' operators to get the 'two parts' ie in your example,

24/10 would give you 2 (integer division) while 24%10 would give you 4

Thank you!!! I'll test it out and let you know how it goes.

IT WORKED!!! Thank you so much!!!

"How do I split a number into its digits?" seems to be a fairly common question.

I wonder if there is a reference or FAQ with answers to questions such as that.