multi digit splitting

the whole code is actually kind of irrelevant but in case u wanna see it.

#include <Keypad.h>
char hexaKeys[4][4] = {
  'A', 'B', 'C', 'D',
  'E', 'F', 'G', 'H',
  'I', 'J', 'K', 'L',
  'M', 'N', 'O', 'P'
};
byte rows = 4; 
byte cols = 4; 
byte rowPins[] = {
  2,3,4,5}; 
byte colPins[] = {
  6,7,8,9}; 


Keypad keypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, rows, cols);
float tempC; 		
int tempPin = 0;
char keyPress [2];
int pressIndex = 0;
int key1 = 0;
int key2 = 0;
int keytot = 0;

void setup(){
  Serial.begin(9600);
  pinMode(32, OUTPUT); 
  pinMode(33, OUTPUT);
  pinMode(34, OUTPUT);
  pinMode(35, OUTPUT);
  pinMode(36, OUTPUT);
  pinMode(37, OUTPUT);
  pinMode(38, OUTPUT);
  pinMode(39, OUTPUT);
  digitalWrite(39, 1);
  pinMode(42, OUTPUT); 
  pinMode(43, OUTPUT);
  pinMode(44, OUTPUT);
  pinMode(45, OUTPUT);
  pinMode(46, OUTPUT);
  pinMode(47, OUTPUT);
  pinMode(48, OUTPUT);
  pinMode(49, OUTPUT);
  digitalWrite(49, 1);
  pinMode(50, OUTPUT);
}

void loop(){
  tempC = analogRead(tempPin); 	
  tempC = (5.0 * tempC * 100.0)/1024.0;  
  Serial.print(tempC); 
  Serial.println(" Grader Celcius"); 	    
  char key = keypad.getKey();
  keytot = (key1 * 10 + key2);
  Serial.println (keytot);
  if ( tempC < (keytot - 1) ) digitalWrite(50 , HIGH);
  else if ( tempC > (keytot + 1) ) digitalWrite(50 , LOW);

  if (key != NO_KEY) {
    key -= 'A'-1;
    keyPress [pressIndex++] = key;
    if (pressIndex == 2) {    
      Serial.println(keyPress[0], DEC);
      Serial.println(keyPress[1], DEC);
      pressIndex = 0;  
    }
    if (keyPress[0] == 1) {
      key1 = 1;
    }
    if (keyPress[0] == 2) {
      key1 = 2;
    }
    if (keyPress[0] == 3) {
      key1 = 3;
    }
    if (keyPress[0] == 5) {
      key1 = 4;
    }
    if (keyPress[0] == 6) {
      key1 = 5;
    }
    if (keyPress[0] == 7) {
      key1 = 6;
    }
    if (keyPress[0] == 9) {
      key1 = 7;
    }
    if (keyPress[0] == 10) {
      key1 = 8;
    }
    if (keyPress[0] == 11) {
      key1 = 9;
    }
    if (keyPress[0] == 14) {
      key1 = 0;
    }
    if (keyPress[1] == 1) {
      key2 = 1;
    }
    if (keyPress[1] == 2) {
      key2 = 2;
    }
    if (keyPress[1] == 3) {
      key2 = 3;
    }
    if (keyPress[1] == 5) {
      key2 = 4;
    }
    if (keyPress[1] == 6) {
      key2 = 5;
    }
    if (keyPress[1] == 7) {
      key2 = 6;
    }
    if (keyPress[1] == 9) {
      key2 = 7;
    }
    if (keyPress[1] == 10) {
      key2 = 8;
    }
    if (keyPress[1] == 11) {
      key2 = 9;
    }
    if (keyPress[1] == 14) {
      key2 = 0;
    }

    if (keyPress[0] == 1){ // 1
      digitalWrite(42, 1);
      digitalWrite(43, 0);
      digitalWrite(44, 0);
      digitalWrite(45, 1);
      digitalWrite(46, 1);
      digitalWrite(47, 1);
      digitalWrite(48, 1);
    }
    if (keyPress[0] == 2){ // 2
      digitalWrite(42, 0);
      digitalWrite(43, 0);
      digitalWrite(44, 1);
      digitalWrite(45, 0);
      digitalWrite(46, 0);
      digitalWrite(47, 1);
      digitalWrite(48, 0);
    }
    if (keyPress[0] == 3) { // 3
      digitalWrite(42, 0);
      digitalWrite(43, 0);
      digitalWrite(44, 0);
      digitalWrite(45, 0);
      digitalWrite(46, 1);
      digitalWrite(47, 1);
      digitalWrite(48, 0);
    }
    if (keyPress[0] == 5) { //4
      digitalWrite(42, 1);
      digitalWrite(43, 0);
      digitalWrite(44, 0);
      digitalWrite(45, 1);
      digitalWrite(46, 1);
      digitalWrite(47, 0);
      digitalWrite(48, 0);
    }
    if (keyPress[0] == 6) { //5
      digitalWrite(42, 0);
      digitalWrite(43, 1);
      digitalWrite(44, 0);
      digitalWrite(45, 0);
      digitalWrite(46, 1);
      digitalWrite(47, 0);
      digitalWrite(48, 0);
    }
    if (keyPress[0] == 7) { //6
      digitalWrite(42, 0);
      digitalWrite(43, 1);
      digitalWrite(44, 0);
      digitalWrite(45, 0);
      digitalWrite(46, 0);
      digitalWrite(47, 0);
      digitalWrite(48, 0);
    }
    if (keyPress[0] == 9) { // 7
      digitalWrite(42, 0);
      digitalWrite(43, 0);
      digitalWrite(44, 0);
      digitalWrite(45, 1);
      digitalWrite(46, 1);
      digitalWrite(47, 1);
      digitalWrite(48, 1);
    }
    if (keyPress[0] == 10) { // 8
      digitalWrite(42, 0);
      digitalWrite(43, 0);
      digitalWrite(44, 0);
      digitalWrite(45, 0);
      digitalWrite(46, 0);
      digitalWrite(47, 0);
      digitalWrite(48, 0);
    }
    if (keyPress[0] == 11) { // 9
      digitalWrite(42, 0);
      digitalWrite(43, 0);
      digitalWrite(44, 0);
      digitalWrite(45, 1);
      digitalWrite(46, 1);
      digitalWrite(47, 0);
      digitalWrite(48, 0);
    }
    if (keyPress[0] == 14) { // 0
      digitalWrite(42, 0);
      digitalWrite(43, 0);
      digitalWrite(44, 0);
      digitalWrite(45, 0);
      digitalWrite(46, 0);
      digitalWrite(47, 0);
      digitalWrite(48, 1);
    }
    if (keyPress[1] == 1){ // 1
      digitalWrite(32, 1);
      digitalWrite(33, 0);
      digitalWrite(34, 0);
      digitalWrite(35, 1);
      digitalWrite(36, 1);
      digitalWrite(37, 1);
      digitalWrite(38, 1);
    }
    if (keyPress[1] == 2){ // 2
      digitalWrite(32, 0);
      digitalWrite(33, 0);
      digitalWrite(34, 1);
      digitalWrite(35, 0);
      digitalWrite(36, 0);
      digitalWrite(37, 1);
      digitalWrite(38, 0);
    }
    if (keyPress[1] == 3) { // 3
      digitalWrite(32, 0);
      digitalWrite(33, 0);
      digitalWrite(34, 0);
      digitalWrite(35, 0);
      digitalWrite(36, 1);
      digitalWrite(37, 1);
      digitalWrite(38, 0);
    }
    if (keyPress[1] == 5) { //4
      digitalWrite(32, 1);
      digitalWrite(33, 0);
      digitalWrite(34, 0);
      digitalWrite(35, 1);
      digitalWrite(36, 1);
      digitalWrite(37, 0);
      digitalWrite(38, 0);
    }
    if (keyPress[1] == 6) { //5
      digitalWrite(32, 0);
      digitalWrite(33, 1);
      digitalWrite(34, 0);
      digitalWrite(35, 0);
      digitalWrite(36, 1);
      digitalWrite(37, 0);
      digitalWrite(38, 0);
    }
    if (keyPress[1] == 7) { //6
      digitalWrite(32, 0);
      digitalWrite(33, 1);
      digitalWrite(34, 0);
      digitalWrite(35, 0);
      digitalWrite(36, 0);
      digitalWrite(37, 0);
      digitalWrite(38, 0);
    }
    if (keyPress[1] == 9) { // 7
      digitalWrite(32, 0);
      digitalWrite(33, 0);
      digitalWrite(34, 0);
      digitalWrite(35, 1);
      digitalWrite(36, 1);
      digitalWrite(37, 1);
      digitalWrite(38, 1);
    }
    if (keyPress[1] == 10) { // 8
      digitalWrite(32, 0);
      digitalWrite(33, 0);
      digitalWrite(34, 0);
      digitalWrite(35, 0);
      digitalWrite(36, 0);
      digitalWrite(37, 0);
      digitalWrite(38, 0);
    }
    if (keyPress[1] == 11) { // 9
      digitalWrite(32, 0);
      digitalWrite(33, 0);
      digitalWrite(34, 0);
      digitalWrite(35, 1);
      digitalWrite(36, 1);
      digitalWrite(37, 0);
      digitalWrite(38, 0);
    }
    if (keyPress[1] == 14) { // 0
      digitalWrite(32, 0);
      digitalWrite(33, 0);
      digitalWrite(34, 0);
      digitalWrite(35, 0);
      digitalWrite(36, 0);
      digitalWrite(37, 0);
      digitalWrite(38, 1);
    }

  }
}

a guy in here helped me convert my 2 keypresses into 1 variable by taking the first one and multiplying it by ten and the second one as it is. so keypress 1 and 3 would become 13 instead of 4 etc.
like this:

 keytot = (key1 * 10 + key2);

now i want to do the same thing but in reverse. i have my variable “tempC”

tempC = analogRead(tempPin); 	
  tempC = (5.0 * tempC * 100.0)/1024.0;

this variable returns a number with 2 digits. i want to split them up into first digit and second digit so i can refer them to my library of numbers at the bottom of the code. in order to show them on my 7segment displays. also i want an unused key ( 4 ) to show the tempC single digits on the 7 segment display and maybe another key ( 8 ) to return to typing in the temperature wanted.

this variable returns a number with 2 digits. i want to split them up into first digit and second digit so i can refer them to my library of numbers at the bottom of the code. in order to show them on my 7segment displays.

How would you do it if the value were a simple decimal number, and all you had was pencil and paper?

Hint:

keytot = (key1 * 10 + key2);

i realize this is something extremely obvious but i’m tired and i can’t see it.

please, spoon feed me :slight_smile:

keytot = (key1 * 10 + key2);

What operation would you perform on "keytot" to determine the value of "key1", knowing that "key1" had been multiplied by ten?

i'm blank. i'm trying to split tempC not keytot . tempC havent been multiplied by ten.

tempC havent been multiplied by ten.

Well, technically, it is the sum of multiple integer powers of two, because it is the result of a successive approximation analogue-to-digital conversion, so it is a sum of products. That's fairly immaterial.

If I give you the decimal value 23, how would you split it into a two and a three?

(sorry, spoon-feeding is not allowed)

Edit: This is not a trick question, and has nothing to do with C/C++, Arduino or computer science.

sorry i havent been able to reply on my own post, my internet went down so had to wait untill now to get to school and answer. anyway.

i got a feeling u want me to say "divide" but that would leave me just as clueless, as i'm not splitting anything up. just reducing the one number severely.

i've never come across anything like this in ordinary math as if i need a number i'll simply write it on a piece of paper. so i'm still just as lost.

23 / 10 = 2 (integer arithmetic) TENS DIGIT

2 * 10 = 20

23 - 20 = 3 UNITS DIGIT