Arduino Nano hardware debug code refining

I’ve been piecing some code together to allow me to manipulate the I/O on an Arduino Nano so that if I have and issues with any PCBs I have made I can fault find them more easily.

Whilst the code seems to work I feel that it is still a little bloated and would like to know how to refine it some, not as though space is an option but I would like ideas for the future.

Any help with this would be appreciated!

/*
Hardware test code for PCMs with arduino nano integrated
Author:   Timmo (arduino@paultimmins.co.uk)
Date:     24 August 2015. 
Modified: .

Serial code manipulated from http://www.gammon.com.au/serial by Nick Gammon
*/

const unsigned int MAX_INPUT = 50;
int IODesignation = 100;
String dataString = "";
String IODesignationString = "";

void setup()
  {
  Serial.begin(57600);
  delay(500);
  IODesignation = 100;
  show_first_menu();
  } // end of setup
  
  
void show_first_menu()
  {
  Serial.write(27);       // ESC command
  Serial.print("[2J");    // clear screen command
  Serial.write(27);
  Serial.print("[H");     // cursor to home command
  Serial.println("Timmo's Arduino Nano hardware debugger"); 
  Serial.println(); 
  Serial.println("Enter I/O designation to manipulate");
  Serial.println("D0-13 or A0-7");
  Serial.println("Enter ? to reshow menu");
  Serial.println(); 
  Serial.print(">");
  } // end show_first_menu
  
  
void show_second_menu()
  {
  Serial.write(27);       // ESC command
  Serial.print("[2J");    // clear screen command
  Serial.write(27);
  Serial.print("[H");     // cursor to home command
  Serial.print(IODesignationString);
  if ((IODesignation >= 0) && (IODesignation < 14))
    {
    Serial.println(" is a digital only pin.");
    Serial.println();
    Serial.println("Enter the corresponding action:");
    Serial.println("1 - Not Applicable");
    Serial.println("2 - Read Digital Input");
    Serial.println("3 - Read Digital Input With Pullups Active");
    Serial.println("4 - Set Output Low");
    Serial.println("5 - Set Output High");
    } // end of if
  else if ((IODesignation >= 14) && (IODesignation < 20))
    {
    Serial.println(" is an analogue pin however digital functions will still work");
    Serial.println();
    Serial.println("Enter the corresponding action:");
    Serial.println("1 - Read Analogue Input");
    Serial.println("2 - Read Digital Input");
    Serial.println("3 - Read Digital Input With Pullups Active");
    Serial.println("4 - Set Output Low");
    Serial.println("5 - Set Output High");
    } // end else if 
  else if ((IODesignation >= 20) && (IODesignation < 22))
    {
    Serial.println(" is an analogue input only pin");
    Serial.println();
    Serial.println("Enter the corresponding action:");
    Serial.println("1 - Read Analogue Input");
    Serial.println("2 - Not Applicable");
    Serial.println("3 - Not Applicable");
    Serial.println("4 - Not Applicable");
    Serial.println("5 - Not Applicable");
    } // end else if
  Serial.println(".");
  Serial.println("0 - Return To Previous Menu");
  Serial.println("Enter ? to reshow menu");
  Serial.println(""); 
  Serial.print(">");
  } // end show_second_menu
  
  
void process_data (const char * data)
  {
  dataString = String(data);
  dataString.trim();
  dataString.toUpperCase();
  if (IODesignation == 100)
    {
    IODesignationString = dataString;
    if (dataString == "D0") {IODesignation = 0;}
    else if (dataString == "D1") {IODesignation = 1;}
    else if (dataString == "D2") {IODesignation = 2;}
    else if (dataString == "D3") {IODesignation = 3;}
    else if (dataString == "D4") {IODesignation = 4;}
    else if (dataString == "D5") {IODesignation = 5;}
    else if (dataString == "D6") {IODesignation = 6;}
    else if (dataString == "D7") {IODesignation = 7;}
    else if (dataString == "D8") {IODesignation = 8;}
    else if (dataString == "D9") {IODesignation = 9;}
    else if (dataString == "D10") {IODesignation = 10;}
    else if (dataString == "D11") {IODesignation = 11;}
    else if (dataString == "D12") {IODesignation = 12;}
    else if (dataString == "D13") {IODesignation = 13;}
    else if (dataString == "A0") {IODesignation = 14;}
    else if (dataString == "A1") {IODesignation = 15;}
    else if (dataString == "A2") {IODesignation = 16;}
    else if (dataString == "A3") {IODesignation = 17;}
    else if (dataString == "A4") {IODesignation = 18;}
    else if (dataString == "A5") {IODesignation = 19;}
    else if (dataString == "A6") {IODesignation = 20;}
    else if (dataString == "A7") {IODesignation = 21;}
    else if (dataString == "?") {show_first_menu();}
    else
      {
      Serial.println(); 
      Serial.print("ERROR: I/O Designation "); 
      Serial.print(dataString); 
      Serial.println(" not recognised!");
      Serial.println("Enter ? to reshow menu");
      Serial.println(); 
      Serial.print(">");
      } // end of else 
    if (IODesignation != 100) {show_second_menu();}
    } // end of else
  else
    {
    int value;
    if ((dataString == "1") && (IODesignation > 13))
      {
      pinMode(IODesignation, INPUT);
      digitalWrite(IODesignation, LOW);
      Serial.print(" Analogue Input Value = ");
      Serial.println(analogRead(IODesignation));
      } // end if
    else if ((dataString == "2") && (IODesignation < 20))
      {
      pinMode(IODesignation, INPUT);
      digitalWrite(IODesignation, LOW);
      Serial.print(" Digital Input = ");
      value = digitalRead(IODesignation);
      if (value) {Serial.println("High");}
      else {Serial.println("Low");}
      Serial.println(">");
      } // end else if
    else if ((dataString == "3") && (IODesignation < 20))
      {
      pinMode(IODesignation, INPUT_PULLUP);
      Serial.print(" Digital Input = ");
      value = digitalRead(IODesignation);
      if (value) {Serial.println("High");}
      else {Serial.println("Low");}
      Serial.println(">");
      } // end else if
    else if ((dataString == "4") && (IODesignation < 20))
      {
      pinMode(IODesignation, OUTPUT);
      Serial.print(" Digital Output");
      digitalWrite(IODesignation, LOW);
      Serial.println(" Set LOW");
      Serial.println(">");
      } // end else if
    else if ((dataString == "5") && (IODesignation < 20))
      {
      pinMode(IODesignation, OUTPUT);
      Serial.print(" Digital Output");
      digitalWrite(IODesignation, HIGH);
      Serial.println(" Set HIGH");
      Serial.println(">");
      } // end else if
    else if (dataString == "0")
      {
        IODesignation = 100;
        show_first_menu();
      } // end else if
    else if (dataString == "?")
      {
        show_second_menu();
      } // end else if
    else
      {
      Serial.println(); 
      Serial.print("ERROR: Action "); 
      Serial.print(dataString); 
      Serial.println(" not recognised!");
      Serial.println("Enter ? to reshow menu");
      Serial.println(); 
      Serial.print(">");
      } // end of else
    } // end of if
  } // end of process_data
  
void processIncomingByte (const byte inByte)
  {
  static char input_line [MAX_INPUT];
  static unsigned int input_pos = 0;

  switch (inByte)
    {
    case '\b':   // ignore backspace character 
      break;
    case '\n':   // end of text
      input_line [input_pos] = 0;  // terminating null byte
      // terminator reached! process input_line here ...
      Serial.println();
      process_data (input_line);
      // reset buffer for next time
      input_pos = 0;  
      break;
    case '\r':   // end of text
      input_line [input_pos] = 0;  // terminating null byte
       // terminator reached! process input_line here ...
      Serial.println();
      process_data (input_line);
      // reset buffer for next time
      input_pos = 0; 
      break;
    default:
      // keep adding if not full ... allow for terminating null byte
      if (input_pos < (MAX_INPUT - 1))
        input_line [input_pos++] = inByte;
        Serial.print(char(inByte));
      break;
    }  // end of switch
  } // end of processIncomingByte  

void loop()
  {
  // if serial data available, process it
  while (Serial.available () > 0)
    processIncomingByte (Serial.read ());
  }  // end of loop

One thing you may want to look at using is the F macro.

Serial.println(F("This string will be stored in flash memory"))

http://playground.arduino.cc/Learning/Memory