How to add 3 digits from keypad to array

I am trying to get a 3 digit number into the first element of an array by getting input from the keypad. The code I have gets the three inputs from the keypad but adds them together instead of adding just the digit .
For example I want the user to enter a three digit number into the keypad for example 135. The way my code is now the first digit is printed correctly ie 1. When the 3 digit is pressed it adds the pressed 3 to the already present 1 to show 4. Then when the 5 is pressed it adds 5 to the existing 4 and shows 9. I need a way to concatenate the input into the array. I've searched the web and forum but haven't found a way. Help please. The code in question is under header "PAGE LEFT TURN". Thanks for any help in pointing me in the right direction.

BTW using Arduino UNO, LCD, and 4 x 4 keypad.

`#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

enum pageType { Main_Menu,
                Menu_2,
                Fwd,
                Rev,
                LTurn,
                RTurn,
                Pause,
                Beep,
                Run,
};
enum pageType currPage = Main_Menu;

byte data_count = 0;
const byte ROWS = 4;
const byte COLS = 4;

char Forward;
char Reverse;
char LeftTurn;
char RightTurn;
char PauseTime;
char BeepTime;


int v =0;
int null = "";
int x = 0;
int t = 0;
int d = 0;
int Time;
int revAmount;
int fwdAmount;
int leftAmount;
int leftRun[10];
int rightAmount;
int rightRun[10];
int runOrder[10];
char runDir[10];
int runDur[10];
int count =0;
int motor1pin1 = 10;  // pin assignment for motors
int motor1pin2 = 13;
int motor2pin1 = 11;
int motor2pin2 = 12;

char hexaKeys[ROWS][COLS] = {  // array for keypad
  { '1', '2', '3', 'A' },
  { '4', '5', '6', 'B' },
  { '7', '8', '9', 'C' },
  { '*', '0', '#', 'D' }
};

byte rowPins[ROWS] = { 9, 8, 7, 6 };  // pin assignments for keypad
byte colPins[COLS] = { 5, 4, 3, 2 };

Keypad customKeypad =
  Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd =
  LiquidCrystal_I2C(0x27, 20, 4);  // Change to (0x27,20,4) for 20x4 LCD.

// ==============================================================================
// ||                               SETUP LOOP ||
// ==============================================================================
void setup() {
  // put your setup code here, to run once:
  pinMode(motor1pin1, OUTPUT);
  pinMode(motor1pin2, OUTPUT);
  pinMode(motor2pin1, OUTPUT);
  pinMode(motor2pin2, OUTPUT);

  // Initiate the LCD:
  lcd.init();
  lcd.backlight();
  lcd.clear();
 }
// ==============================================================================
// ||                              MAIN LOOP                                 ||
// ==============================================================================
void loop() {
  // put your main code here, to run repeatedly:
  switch (currPage) {  // start menu system
    case Main_Menu:
      page_Main_Menu();
      break;
  }
 }
// ==============================================================================
// ||                               PAGE MAIN MENU called from void loop       ||
// ==============================================================================
void page_Main_Menu() {  // print menu
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("     MAIN MENU");
  lcd.setCursor(0, 1);
  lcd.print("1. FWD     2. REV");
  lcd.setCursor(0, 2);
  lcd.print("3. LTURN   4. RTURN");
  lcd.setCursor(0, 3);
  lcd.print("5. NEXT    #. RUN");
  char customKey = customKeypad.waitForKey();

  if (customKey) {  // get input from menu
    switch (customKey) {
      case '1':
        page_Fwd();
        break;
      case '2':
        page_Rev();
        break;
      case '3':
        page_LTurn();
        break;
      case '4':
        page_RTurn();
        break;
      case '5':
        page_Menu_2();
        break;
      case '#':
        page_Run();
        break;
      default:
        lcd.clear();
        lcd.setCursor(8, 0);
        lcd.print("Error");
        delay(2000);
        currPage = Main_Menu;
        break;
    }
  }
 }
// ==============================================================================
// ||                               PAGE MENU 2   called from Main Menu        ||
// ==============================================================================
void page_Menu_2() {  // print menu
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("       MENU 2");
  lcd.setCursor(0, 1);
  lcd.print("6. BEEP    7. PAUSE");
  lcd.setCursor(0, 2);
  lcd.print("8.         9.    ");
  lcd.setCursor(0, 3);
  lcd.print("B. BACK    #. RUN");
  char customKey = customKeypad.waitForKey();

  if (customKey) {  // get input from menu
    switch (customKey) {
      case '6':
        page_Beep();
        break;
      case '7':
        page_Pause();
        break;
      case 'B':
        page_Main_Menu();
        break;
      case '#':
        page_Run();
        break;
      default:
        lcd.clear();
        lcd.setCursor(8, 0);
        lcd.print("Error");
        delay(2000);
        currPage = Menu_2;
        break;
    }
  }
 }
// ==============================================================================
// ||                               PAGE FORWARD called from main menu          ||
// ==============================================================================
void page_Fwd() {  // print menu
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("Distance in Feet");
  lcd.setCursor(6, 1);
  lcd.print(" 1 to 9");
  lcd.setCursor(9, 2);
  lcd.blink();
  char Forward = customKeypad.waitForKey();
  if (Forward >= '0' && Forward <= '9') {  // weed out unavailable input
    runDur[x] = Forward - '0';
    runDir[x] = 'F';
    lcd.noBlink();
    runOrder[x] = runDir[x];
    x++;
    }

  else {
    lcd.setCursor(9, 2);
    lcd.print("Error");
    delay(2000);
    lcd.clear();
    page_Fwd();
  }
 }
// ==============================================================================
// ||                               PAGE REVERSE ||
// ==============================================================================
void page_Rev() {  // print menu
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("Distance in Feet");
  lcd.setCursor(6, 1);
  lcd.print(" 1 to 9");
  lcd.setCursor(9, 2);
  lcd.blink();
  char Reverse = customKeypad.waitForKey();

  if (Reverse >= '0' && Reverse <= '9') {  // weed out unavailable input
    runDur[x] = Reverse - '0';
    runDir[x] = 'B';
    lcd.noBlink();
    runOrder[x] = runDir[x];
    x++;
  } else {
    lcd.setCursor(9, 2);
    lcd.print("Error");
    delay(2000);
    currPage = Rev;
  }
 }
// ==============================================================================
// ||                               PAGE LEFT TURN ||
// ==============================================================================
void page_LTurn() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Direction in Degrees");
  lcd.setCursor(6, 1);
  lcd.print(" 1 to 359");
  lcd.setCursor(9, 2);
  lcd.blink();
  do {
  char key = customKeypad.waitForKey();

  if (key >= '0' && key <= '9')   // weed out unavailable input
     
    LeftTurn = key -'0';
   
    runDur[x] += LeftTurn ;
    lcd.print (runDur[x]);
   count++;
    currPage = LTurn;
}
  while (count >= 0 && count <=2);
  delay(1000);
  runDir[x] = 'L';
  lcd.noBlink();
  runOrder[x] = runDir[x];
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print (runDur[x]);
  lcd.setCursor(0, 1);
  lcd.print (runDir[x]);
  lcd.setCursor (0, 2);
  lcd.print (runOrder[x]);
  delay(2000);
  x++;
  cleanUp();
  currPage = Main_Menu;
 } 
 // ==============================================================================
// ||                               PAGE RIGHT TURN ||
// ==============================================================================
void page_RTurn() {
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("Direction in Degrees");
  lcd.setCursor(6, 1);
  lcd.print(" 1 to 359");
  lcd.setCursor(9, 2);
  lcd.blink();
  char LeftTurn = customKeypad.waitForKey();

  if (RightTurn >= '0' && RightTurn <= '9') {  // weed out unavailable input
    runDur[x] = RightTurn - '0';
    runDir[x] = 'R';
    lcd.noBlink();
    runOrder[x] = runDir[x];
    x++;
  } else {
    lcd.setCursor(9, 2);
    lcd.print("Error");
    delay(2000);
    currPage = RTurn;
  }
 }
// ==============================================================================
// ||                               PAGE PAUSE                                ||
// ==============================================================================
void page_Pause() {}
// ==============================================================================
// ||                               PAGE BEEP                                ||
// ==============================================================================
void page_Beep() {}
// ==============================================================================
// ||                               PAGE RUN    called from menus             ||
// ==============================================================================
void page_Run() {
  lcd.clear();
  lcd.setCursor(4, 0);
  lcd.print("RUN PROGRAM");
  delay(2000);
  while (runOrder[d] != null){
  if (runDir[d] == 70) {  //ascii for F
    runDur[d] = (runDur[d] * 2000);
    forwardRun();
    d = (d + 1);
  } else if (runDir[d] == 66) {  //ascii for B
    runDur[d] = (runDur[d] * 2000);
    reverseRun();
    d = (d + 1);
  } else if (runDir[d] == 76) {  //ascii for L
    runDur[d] = (runDur[d] * 2000);
    LTurnRun();
    d = (d + 1);
  } else if (runDir[d] == 82) {  //ascii for R
    runDur[d] = (runDur[d] * 2000);
    RTurnRun();
    d = (d + 1);
  } else {
    lcd.clear();
    lcd.setCursor(8,1);
    lcd.print("DONE");
    delay(2000);
    
    break;
    
  }
   }
   
 cleanUp();
  currPage = Main_Menu;
 }
 // ==============================================================================
// ||                               CLEAN UP                                     ||
// ==============================================================================
void cleanUp(){
 lcd.clear();
 lcd.setCursor(6,0);
 lcd.print("CLEAN UP");
 delay(2000);

 lcd.clear();
 lcd.setCursor(6,0);
 lcd.print (runDir[2]);
 lcd.setCursor(6,1);
 lcd.print (runDur[2]);
 lcd.setCursor(6,2);
 lcd.print (runOrder[2]);
 lcd.setCursor(6,3);
 lcd.print (x);
 lcd.print(d);
 delay(2000);
   
 memset(runDir, '\0', sizeof(runDir));      // clear arrays
 memset(runDur, '\0', sizeof(runDur));
 memset(runOrder, '\0', sizeof(runOrder));
 count = 0;

 lcd.clear();
 lcd.blink();
 lcd.setCursor(6,0);
 lcd.print (runDir[2]);
 lcd.setCursor(6,1);
 lcd.print (runDur[2]);
 lcd.setCursor(6,2);
 lcd.print (runOrder[2]);
 lcd.setCursor(6,3);
 lcd.print (x);
 lcd.print(d);
 delay(2000);
 lcd.noBlink();
 }
// ==============================================================================
// ||                               PAGE forward run  called from Run          ||
// ==============================================================================
void forwardRun() {
  lcd.clear();
  lcd.setCursor(6, 0);
  lcd.print("FORWARD ");


  digitalWrite(motor1pin1, LOW);  // turn motor on
  digitalWrite(motor1pin2, HIGH);
  digitalWrite(motor2pin1, HIGH);
  digitalWrite(motor2pin2, LOW);
  Time = runDur[t];
  delay(Time);                    // TIME MOTOR RUNS
  digitalWrite(motor1pin1, LOW);  // turn motor off
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, LOW);
  delay(250);
  t = t + 1;
 }
// ==============================================================================
// ||                               PAGE reverse run  called from Run          ||
// ==============================================================================
void reverseRun() {
  lcd.clear();
  lcd.setCursor(6, 0);
  lcd.print("REVERSE ");


  digitalWrite(motor1pin1, HIGH);  // turn motor on
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, HIGH);
  Time = runDur[t];
  delay(Time);                    // TIME MOTOR RUNS
  digitalWrite(motor1pin1, LOW);  // turn motor off
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, LOW);
  delay(250);
  t = t + 1;
 }
// ==============================================================================
// ||                               PAGE LTurn run  called from Run          ||
// ==============================================================================
void LTurnRun() {
  lcd.clear();
  lcd.setCursor(6, 0);
  lcd.print("LEFT TURN ");


  digitalWrite(motor1pin1, LOW);  // turn motor on
  digitalWrite(motor1pin2, HIGH);
  digitalWrite(motor2pin1, HIGH);
  digitalWrite(motor2pin2, LOW);
  Time = runDur[0];
  delay(Time);                    // TIME MOTOR RUNS
  digitalWrite(motor1pin1, LOW);  // turn motor off
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, LOW);
  delay(250);
 }
// ==============================================================================
// ||                               PAGE RTurn run  called from Run          ||
// ==============================================================================
void RTurnRun() {
  lcd.clear();
  lcd.setCursor(6, 0);
  lcd.print("RIGHT TURN ");


  digitalWrite(motor1pin1, HIGH);  // turn motor on
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, HIGH);
  Time = runDur[0];
  delay(Time);                    // TIME MOTOR RUNS
  digitalWrite(motor1pin1, LOW);  // turn motor off
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, LOW);
  delay(250);
 }`

Please apply standard indentation to your sketch using ctrl-T and post in a new message.

sorry here it is. I'm still learning.

#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>

enum pageType { Main_Menu,
                Menu_2,
                Fwd,
                Rev,
                LTurn,
                RTurn,
                Pause,
                Beep,
                Run,
};
enum pageType currPage = Main_Menu;

byte data_count = 0;
const byte ROWS = 4;
const byte COLS = 4;

char Forward;
char Reverse;
char LeftTurn;
char RightTurn;
char PauseTime;
char BeepTime;


int v =0;
int null = "";
int x = 0;
int t = 0;
int d = 0;
int Time;
int revAmount;
int fwdAmount;
int leftAmount;
int leftRun[10];
int rightAmount;
int rightRun[10];
int runOrder[10];
char runDir[10];
int runDur[10];
int count =0;
int motor1pin1 = 10;  // pin assignment for motors
int motor1pin2 = 13;
int motor2pin1 = 11;
int motor2pin2 = 12;

char hexaKeys[ROWS][COLS] = {  // array for keypad
  { '1', '2', '3', 'A' },
  { '4', '5', '6', 'B' },
  { '7', '8', '9', 'C' },
  { '*', '0', '#', 'D' }
};

byte rowPins[ROWS] = { 9, 8, 7, 6 };  // pin assignments for keypad
byte colPins[COLS] = { 5, 4, 3, 2 };

Keypad customKeypad =
  Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd =
  LiquidCrystal_I2C(0x27, 20, 4);  // Change to (0x27,20,4) for 20x4 LCD.

// ==============================================================================
// ||                               SETUP LOOP ||
// ==============================================================================
void setup() {
  // put your setup code here, to run once:
  pinMode(motor1pin1, OUTPUT);
  pinMode(motor1pin2, OUTPUT);
  pinMode(motor2pin1, OUTPUT);
  pinMode(motor2pin2, OUTPUT);

  // Initiate the LCD:
  lcd.init();
  lcd.backlight();
  lcd.clear();
 }
// ==============================================================================
// ||                              MAIN LOOP                                 ||
// ==============================================================================
void loop() {
  // put your main code here, to run repeatedly:
  switch (currPage) {  // start menu system
    case Main_Menu:
      page_Main_Menu();
      break;
  }
 }
// ==============================================================================
// ||                               PAGE MAIN MENU called from void loop       ||
// ==============================================================================
void page_Main_Menu() {  // print menu
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("     MAIN MENU");
  lcd.setCursor(0, 1);
  lcd.print("1. FWD     2. REV");
  lcd.setCursor(0, 2);
  lcd.print("3. LTURN   4. RTURN");
  lcd.setCursor(0, 3);
  lcd.print("5. NEXT    #. RUN");
  char customKey = customKeypad.waitForKey();

  if (customKey) {  // get input from menu
    switch (customKey) {
      case '1':
        page_Fwd();
        break;
      case '2':
        page_Rev();
        break;
      case '3':
        page_LTurn();
        break;
      case '4':
        page_RTurn();
        break;
      case '5':
        page_Menu_2();
        break;
      case '#':
        page_Run();
        break;
      default:
        lcd.clear();
        lcd.setCursor(8, 0);
        lcd.print("Error");
        delay(2000);
        currPage = Main_Menu;
        break;
    }
  }
 }
// ==============================================================================
// ||                               PAGE MENU 2   called from Main Menu        ||
// ==============================================================================
void page_Menu_2() {  // print menu
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("       MENU 2");
  lcd.setCursor(0, 1);
  lcd.print("6. BEEP    7. PAUSE");
  lcd.setCursor(0, 2);
  lcd.print("8.         9.    ");
  lcd.setCursor(0, 3);
  lcd.print("B. BACK    #. RUN");
  char customKey = customKeypad.waitForKey();

  if (customKey) {  // get input from menu
    switch (customKey) {
      case '6':
        page_Beep();
        break;
      case '7':
        page_Pause();
        break;
      case 'B':
        page_Main_Menu();
        break;
      case '#':
        page_Run();
        break;
      default:
        lcd.clear();
        lcd.setCursor(8, 0);
        lcd.print("Error");
        delay(2000);
        currPage = Menu_2;
        break;
    }
  }
 }
// ==============================================================================
// ||                               PAGE FORWARD called from main menu          ||
// ==============================================================================
void page_Fwd() {  // print menu
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("Distance in Feet");
  lcd.setCursor(6, 1);
  lcd.print(" 1 to 9");
  lcd.setCursor(9, 2);
  lcd.blink();
  char Forward = customKeypad.waitForKey();
  if (Forward >= '0' && Forward <= '9') {  // weed out unavailable input
    runDur[x] = Forward - '0';
    runDir[x] = 'F';
    lcd.noBlink();
    runOrder[x] = runDir[x];
    x++;
    }

  else {
    lcd.setCursor(9, 2);
    lcd.print("Error");
    delay(2000);
    lcd.clear();
    page_Fwd();
  }
 }
// ==============================================================================
// ||                               PAGE REVERSE ||
// ==============================================================================
void page_Rev() {  // print menu
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("Distance in Feet");
  lcd.setCursor(6, 1);
  lcd.print(" 1 to 9");
  lcd.setCursor(9, 2);
  lcd.blink();
  char Reverse = customKeypad.waitForKey();

  if (Reverse >= '0' && Reverse <= '9') {  // weed out unavailable input
    runDur[x] = Reverse - '0';
    runDir[x] = 'B';
    lcd.noBlink();
    runOrder[x] = runDir[x];
    x++;
  } else {
    lcd.setCursor(9, 2);
    lcd.print("Error");
    delay(2000);
    currPage = Rev;
  }
 }
// ==============================================================================
// ||                               PAGE LEFT TURN ||
// ==============================================================================
void page_LTurn() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Direction in Degrees");
  lcd.setCursor(6, 1);
  lcd.print(" 1 to 359");
  lcd.setCursor(9, 2);
  lcd.blink();
  do {
  char key = customKeypad.waitForKey();

  if (key >= '0' && key <= '9')   // weed out unavailable input
     
    LeftTurn = key -'0';
   
    runDur[x] += LeftTurn ;
    lcd.print (runDur[x]);
   count++;
    currPage = LTurn;
}
  while (count >= 0 && count <=2);
  delay(1000);
  runDir[x] = 'L';
  lcd.noBlink();
  runOrder[x] = runDir[x];
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print (runDur[x]);
  lcd.setCursor(0, 1);
  lcd.print (runDir[x]);
  lcd.setCursor (0, 2);
  lcd.print (runOrder[x]);
  delay(2000);
  x++;
  cleanUp();
  currPage = Main_Menu;
 } 
 // ==============================================================================
// ||                               PAGE RIGHT TURN ||
// ==============================================================================
void page_RTurn() {
  lcd.clear();
  lcd.setCursor(2, 0);
  lcd.print("Direction in Degrees");
  lcd.setCursor(6, 1);
  lcd.print(" 1 to 359");
  lcd.setCursor(9, 2);
  lcd.blink();
  char LeftTurn = customKeypad.waitForKey();

  if (RightTurn >= '0' && RightTurn <= '9') {  // weed out unavailable input
    runDur[x] = RightTurn - '0';
    runDir[x] = 'R';
    lcd.noBlink();
    runOrder[x] = runDir[x];
    x++;
  } else {
    lcd.setCursor(9, 2);
    lcd.print("Error");
    delay(2000);
    currPage = RTurn;
  }
 }
// ==============================================================================
// ||                               PAGE PAUSE                                ||
// ==============================================================================
void page_Pause() {}
// ==============================================================================
// ||                               PAGE BEEP                                ||
// ==============================================================================
void page_Beep() {}
// ==============================================================================
// ||                               PAGE RUN    called from menus             ||
// ==============================================================================
void page_Run() {
  lcd.clear();
  lcd.setCursor(4, 0);
  lcd.print("RUN PROGRAM");
  delay(2000);
  while (runOrder[d] != null){
  if (runDir[d] == 70) {  //ascii for F
    runDur[d] = (runDur[d] * 2000);
    forwardRun();
    d = (d + 1);
  } else if (runDir[d] == 66) {  //ascii for B
    runDur[d] = (runDur[d] * 2000);
    reverseRun();
    d = (d + 1);
  } else if (runDir[d] == 76) {  //ascii for L
    runDur[d] = (runDur[d] * 2000);
    LTurnRun();
    d = (d + 1);
  } else if (runDir[d] == 82) {  //ascii for R
    runDur[d] = (runDur[d] * 2000);
    RTurnRun();
    d = (d + 1);
  } else {
    lcd.clear();
    lcd.setCursor(8,1);
    lcd.print("DONE");
    delay(2000);
    
    break;
    
  }
   }
   
 cleanUp();
  currPage = Main_Menu;
 }
 // ==============================================================================
// ||                               CLEAN UP                                     ||
// ==============================================================================
void cleanUp(){
 lcd.clear();
 lcd.setCursor(6,0);
 lcd.print("CLEAN UP");
 delay(2000);

 lcd.clear();
 lcd.setCursor(6,0);
 lcd.print (runDir[2]);
 lcd.setCursor(6,1);
 lcd.print (runDur[2]);
 lcd.setCursor(6,2);
 lcd.print (runOrder[2]);
 lcd.setCursor(6,3);
 lcd.print (x);
 lcd.print(d);
 delay(2000);
   
 memset(runDir, '\0', sizeof(runDir));      // clear arrays
 memset(runDur, '\0', sizeof(runDur));
 memset(runOrder, '\0', sizeof(runOrder));
 count = 0;

 lcd.clear();
 lcd.blink();
 lcd.setCursor(6,0);
 lcd.print (runDir[2]);
 lcd.setCursor(6,1);
 lcd.print (runDur[2]);
 lcd.setCursor(6,2);
 lcd.print (runOrder[2]);
 lcd.setCursor(6,3);
 lcd.print (x);
 lcd.print(d);
 delay(2000);
 lcd.noBlink();
 }
// ==============================================================================
// ||                               PAGE forward run  called from Run          ||
// ==============================================================================
void forwardRun() {
  lcd.clear();
  lcd.setCursor(6, 0);
  lcd.print("FORWARD ");


  digitalWrite(motor1pin1, LOW);  // turn motor on
  digitalWrite(motor1pin2, HIGH);
  digitalWrite(motor2pin1, HIGH);
  digitalWrite(motor2pin2, LOW);
  Time = runDur[t];
  delay(Time);                    // TIME MOTOR RUNS
  digitalWrite(motor1pin1, LOW);  // turn motor off
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, LOW);
  delay(250);
  t = t + 1;
 }
// ==============================================================================
// ||                               PAGE reverse run  called from Run          ||
// ==============================================================================
void reverseRun() {
  lcd.clear();
  lcd.setCursor(6, 0);
  lcd.print("REVERSE ");


  digitalWrite(motor1pin1, HIGH);  // turn motor on
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, HIGH);
  Time = runDur[t];
  delay(Time);                    // TIME MOTOR RUNS
  digitalWrite(motor1pin1, LOW);  // turn motor off
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, LOW);
  delay(250);
  t = t + 1;
 }
// ==============================================================================
// ||                               PAGE LTurn run  called from Run          ||
// ==============================================================================
void LTurnRun() {
  lcd.clear();
  lcd.setCursor(6, 0);
  lcd.print("LEFT TURN ");


  digitalWrite(motor1pin1, LOW);  // turn motor on
  digitalWrite(motor1pin2, HIGH);
  digitalWrite(motor2pin1, HIGH);
  digitalWrite(motor2pin2, LOW);
  Time = runDur[0];
  delay(Time);                    // TIME MOTOR RUNS
  digitalWrite(motor1pin1, LOW);  // turn motor off
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, LOW);
  delay(250);
 }
// ==============================================================================
// ||                               PAGE RTurn run  called from Run          ||
// ==============================================================================
void RTurnRun() {
  lcd.clear();
  lcd.setCursor(6, 0);
  lcd.print("RIGHT TURN ");


  digitalWrite(motor1pin1, HIGH);  // turn motor on
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, HIGH);
  Time = runDur[0];
  delay(Time);                    // TIME MOTOR RUNS
  digitalWrite(motor1pin1, LOW);  // turn motor off
  digitalWrite(motor1pin2, LOW);
  digitalWrite(motor2pin1, LOW);
  digitalWrite(motor2pin2, LOW);
  delay(250);
 }

It looks to me like you might have missing or extra {} in this...

I tried adding the {} at the end of the if (code below) with no change. I think my biggest problem is adding the second and third digits to the first element of the array. The += doesn't work, is there a way to add a char to the already populated array. In Visual Basic there was concatenate. not sure how to do it here. Either that or store 3 keys into a variable then add to array.

 if (key >= '0' && key <= '9') {  // weed out unavailable input
     
    LeftTurn = key -'0';
   
    runDur[x] += LeftTurn ;
    lcd.print (runDur[x]);
   count++;
    currPage = LTurn;
  }
}

For anyone out there looking for an answer to a similar problem here is how I solved it.

 if (key >= '0' && key <= '9')   // weed out unavailable input
     
    LeftTurn = key -'0';
    switch(count){
    
    case 0:
      d1 =LeftTurn;
      lcd.print(d1);
      break;
    
    case 1:
      d1 = (d1 * 10);
      d2 = LeftTurn;
      lcd.print(d2);
      break;

    case 2:
    d1 = (d1 * 10);
    d2 = (d2 * 10);
    d3 = LeftTurn;
    lcd.print(d3);
    
    }
    
   count++;
    currPage = LTurn;
}

Why? You made no effort to understand it, just copy and pasted verbatim. Your biggest problem seems to be a lack of familiarity with C/C++ statement syntax. That is not hard to correct. The proper form of an 'if' statement is not complex, it's documented both on the reference page on this site, and widely on the internet, on C/C++ reference and tutorial sites.

Yes, my familiarity with C++ is very limited. I'm trying to teach myself. Thats why I posted the question. I didn't expect to get berated for asking "dumb" questions. I did try to understand it, but as i said I'm still learning. BTW if you look at my last post I figured out what I wanted to do without any help.

I did. I availed myself of all the original source information I could possibly get my hands on. To learn effectively, you need to pause and resolve a question before moving on. It seems, the revised sketch you posted used a completely different method, and so you missed an opportunity to really grasp the reason behind the mistake that you made.

I never berated you for asking a dumb question. Go back and see.

Did you investigate, based on the suggestion of resources that I made? That would be a great learning opportunity.

1 Like

That is precisely what the code you posted does. 'count' is the index, points to the next available position in the array. The code adds a character, and increments the index. That is a concatenation. The only problem, it should just be an assignment '=' and not a compound form of addition '+='.

Did you write the code from scratch, or attempt to modify someone else's code? Because, the "skeleton" of the correct logic is there. Yet you seem to not understand it.

Yes i wrote it from scratch. I tried just using the = but it would only change the element of the array not add another diget. No i haven't looked at your suggestions yet as im away from my computer now, but i will look. Sorry i got defensive but I'm such a noob that your explanation wasn't spelled out enough for me to understand.

Then the index increment failed. Adding the element is supposed to happen, but the index has to be advanced to the next location to accept the next element.

I think you are misunderstanding wha I was trying to do. What I was attempting to do is take 3 keypad inputs and put them into the 0 element of the array. I was indexing to get second and third keypad entries. Maybe I'm just not getting what your trying to explain. This 60yr old dog has trouble learning new tricks. Lol.

put wait_for_key in a loop. Each time the number is entered add it to a c_string variable using strcat() function. You will also use a count variable, increment that each time the number is entered.
when it reaches 3 exit the loop.

Get that working then you will have to work on changing the string to an integer.

There is prob., an easier way to do it.

Taken literally, that would mean overwriting the first input twice. I doubt that is what you mean so I'm lost.

Pseudocode:

size = 3
index = 0
while index < size
{
  array[index] = the new character
  increment the index
}

No you're right on or close. I was trying to append the second and third digits to the first input. Maybe i was trying to do something that can't be done.

It's done constantly every day in millions of programs. You seem to be hung up on the concept of "append". For a fixed length character string, you can only append, based on identifying some character as the "current" character. That is what your variable 'count' was doing.

A variable length character string is also a character array fixed in memory (in C), but the "end" is signified by and end marker character, a 'null'.

That can be done. Is that what you still want to do.

1 Like

Its so difficult to explain through text what i mean. Either way i figured out a way to get the result i was after. . Maybe tomorrow when im at computer and not typing on phone i can explain better. Thank you for trying to help

Please do, there are also lots more helpers here that may chime in. Best way is to distill it down to a simple example.