Data dump slow response with led a fast response

With this code I want to have my LED’s respond quickly, but with the data being displayed I want a 1/2 second to a second delay.

#include <SPI.h>
#include "Adafruit_MAX31855.h"

#define pHpin A10            //pH meter Analog output to Arduino Analog Input 0
#define MoisturePin A8          // select the input pin for the potentiometer
#define Offset 0.12            //deviation compensate
#define LED 13
#define samplingInterval 20
#define printInterval 500
#define ArrayLenth  40    //times of collection
#define DO   3  
#define CS   4
#define CLK  5

int pHArray[ArrayLenth];   //Store the average value of the sensor feedback
int pHArrayIndex=0;
int pHValue;

double temp;

float sensorValue;
float MoistureValue;

Adafruit_MAX31855 thermocouple(CLK, CS, DO);


//LED pin layout
int TEMPred = 22;
int TEMPamber = 24;
int TEMPgreen = 26;


int MOIred = 30;
int MOIamber = 32;
int MOIgreen = 34;

int pHred = 38;
int pHamber = 40;
int pHgreen = 42;



void setup(void)
{
  pinMode(TEMPgreen,OUTPUT);
  pinMode(TEMPamber,OUTPUT);
  pinMode(TEMPred,OUTPUT);

  pinMode(MOIgreen,OUTPUT);
  pinMode(MOIamber,OUTPUT);
  pinMode(MOIred,OUTPUT);

  pinMode(pHgreen,OUTPUT);
  pinMode(pHamber,OUTPUT);
  pinMode(pHred,OUTPUT);
  pinMode(LED,OUTPUT);  
  Serial.begin(9600);  
  Serial.print("MAX31855 test");
  Serial.print("Ready");    
  Serial.println("");
  // wait for MAX chip to stabilize

  delay(500);

  Serial.write(27);       
  Serial.print("[2J");    
  Serial.write(27);
  Serial.print("[H");     

}

void loop(void)
{

  digitalWrite(LED,LOW);
  //Moisture sensor

  sensorValue = analogRead(MoisturePin);    
  MoistureValue= 0.5741*(pow(2.71828,(0.0078*sensorValue)));


  // Temperature 
  double c = thermocouple.readCelsius();
  double temp = 1.0212 * c + 0.3663;

  //pH sensor

  static unsigned long samplingTime = millis();
  static unsigned long printTime = millis();
  static float pHValue,voltage;
  if(millis()-samplingTime > samplingInterval)
  {
    pHArray[pHArrayIndex++]=analogRead(pHpin);
    if(pHArrayIndex==ArrayLenth)pHArrayIndex=0;
    voltage = avergearray(pHArray, ArrayLenth)*5.0/1024;
    pHValue = 3.5*voltage+Offset;
    samplingTime=millis();
  }
  Serial.write(27);       
  Serial.print("[2J");    
  Serial.write(27);
  Serial.print("[H"); 
  Serial.println("ADAQ1000 Data");
  if(millis() - printTime > printInterval)   //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
  {
    // pH LED display sensor readings

    if(pHValue >= 0 && pHValue <= 6)
    {
      Serial.print(" pH: ");  
      Serial.print(pHValue,1);
      digitalWrite(pHred,LOW);
      digitalWrite(pHamber, HIGH);
      digitalWrite(pHgreen, HIGH);
    }
    else if (pHValue >=6 && pHValue <= 6.5)
    {
      Serial.print(" pH: ");  
      Serial.print(pHValue,1);
      digitalWrite(pHamber, LOW);
      digitalWrite(pHgreen, HIGH);
      digitalWrite(pHred, HIGH); 
    }
    else if (pHValue >=6.5 && pHValue <= 7.5)
    {
      Serial.print(" pH: ");  
      Serial.print(pHValue,1);
      digitalWrite(pHamber, HIGH);
      digitalWrite(pHgreen, LOW);
      digitalWrite(pHred, HIGH); 
    }
    else if (pHValue >=7.5 && pHValue <= 8.5)
    {
      Serial.print(" pH: ");  
      Serial.print(pHValue,1);
      digitalWrite(pHamber, LOW);
      digitalWrite(pHgreen, HIGH);
      digitalWrite(pHred, HIGH); 
    }
    else if (pHValue >=8.5 && pHValue <= 14)
    {
      Serial.print(" pH: ");  
      Serial.print(pHValue,1);
      digitalWrite(pHamber, HIGH);
      digitalWrite(pHgreen, HIGH);
      digitalWrite(pHred, LOW); 
    }
  }
  // Temperature LED display sensor readings

  if(temp >= 0 && temp <= 5)
  {
    Serial.print(" Temperature 1 ");
    Serial.write (176);
    Serial.write (67);
    Serial.write(58 ); 
    Serial.print(" ");
    Serial.print(temp,1 );
    digitalWrite(TEMPred,LOW);
    digitalWrite(TEMPamber, HIGH);
    digitalWrite(TEMPgreen, HIGH);

  }
  else if (temp >=5 && temp <= 10)
  {
    Serial.print(" Temperature 1 ");
    Serial.write (176);
    Serial.write (67);
    Serial.write(58 ); 
    Serial.print(" ");
    Serial.print(temp,1 );
    digitalWrite(TEMPamber, LOW);
    digitalWrite(TEMPgreen, HIGH);
    digitalWrite(TEMPred, HIGH);

  }
  else if (temp >=10 && temp <= 35)
  {

    Serial.print(" Temperature 1 ");
    Serial.write (176);
    Serial.write (67);
    Serial.write(58 ); 
    Serial.print(" ");
    Serial.print(temp,1 );
    digitalWrite(TEMPamber, HIGH);
    digitalWrite(TEMPgreen, LOW);
    digitalWrite(TEMPred, HIGH);

  }
  else if (temp >=35 && temp <= 40)
  {
    Serial.print(" Temperature 1 ");
    Serial.write (176);
    Serial.write (67);
    Serial.write(58 ); 
    Serial.print(" ");
    Serial.print(temp,1 );
    digitalWrite(TEMPamber, LOW);
    digitalWrite(TEMPgreen, HIGH);
    digitalWrite(TEMPred, HIGH);

  }
  else if (temp >=40 && temp <= 45)
  {
    Serial.print(" Temperature 1 ");
    Serial.write (176);
    Serial.write (67);
    Serial.write(58 ); 
    Serial.print(" ");
    Serial.print(temp,1 );
    digitalWrite(TEMPamber, HIGH);
    digitalWrite(TEMPgreen, HIGH);
    digitalWrite(TEMPred, LOW);

  }

  // Moisture LED display sensor readings 

  if(MoistureValue >= 0 && MoistureValue <= 20)
  {
    Serial.print(" ");

    Serial.print(" ");
    Serial.write(37);
    Serial.print(" Moisture");
    Serial.write(58);
    Serial.print(" ");
    Serial.print( MoistureValue ,0);
    digitalWrite(MOIred,LOW);
    digitalWrite(MOIamber, HIGH);
    digitalWrite(MOIgreen, HIGH);
  }
  else if (MoistureValue >=20 && MoistureValue <= 35)
  {
    Serial.print(" ");
    Serial.write(37);
    Serial.print(" Moisture");
    Serial.write(58);
    Serial.print(" ");
    Serial.print( MoistureValue ,0);
    digitalWrite(MOIamber, LOW);
    digitalWrite(MOIgreen, HIGH);
    digitalWrite(MOIred, HIGH); 
  }
  else if (MoistureValue >=35 && MoistureValue <= 65)
  {

    Serial.print(" ");
    Serial.write(37);
    Serial.print(" Moisture");
    Serial.write(58);
    Serial.print(" ");
    Serial.print( MoistureValue ,0);
    digitalWrite(MOIamber, HIGH);
    digitalWrite(MOIgreen, LOW);
    digitalWrite(MOIred, HIGH); 
  }
  else if (MoistureValue >=65 && MoistureValue <= 70)
  {
    Serial.print(" ");
    Serial.write(37);
    Serial.print(" Moisture");
    Serial.write(58);
    Serial.print(" ");
    Serial.print( MoistureValue ,0);
    digitalWrite(MOIamber, LOW);
    digitalWrite(MOIgreen, HIGH);
    digitalWrite(MOIred, HIGH); 
  }
  else if (MoistureValue >=70 && MoistureValue <= 100)
  {
    Serial.print(" ");
    Serial.write(37);
    Serial.print(" Moisture");
    Serial.write(58);
    Serial.print(" ");
    Serial.print( MoistureValue ,0);
    digitalWrite(MOIamber, HIGH);
    digitalWrite(MOIgreen, HIGH);
    digitalWrite(MOIred, LOW); 
  }

}
double avergearray(int* arr, int number){
  int i;
  int max,min;
  double avg;
  long amount=0;
  if(number<=0){
    Serial.println("Error number for the array to avraging!/n");
    return 0;
  }
  if(number<5){   //less than 5, calculated directly statistics
    for(i=0;i<number;i++){
      amount+=arr[i];
    }
    avg = amount/number;
    return avg;
  }
  else{
    if(arr[0]<arr[1]){
      min = arr[0];
      max=arr[1];
    }
    else{
      min=arr[1];
      max=arr[0];
    }
    for(i=2;i<number;i++){
      if(arr[i]<min){
        amount+=min;        //arr<min
        min=arr[i];
      }
      else {
        if(arr[i]>max){
          amount+=max;    //arr>max
          max=arr[i];
        }
        else{
          amount+=arr[i]; //min<=arr<=max
        }
      }//if
    }//for
    avg = (double)amount/(number-2);
  }//if
  return avg;
}

jkarpynczyk:
With this code I want to have my LED's respond quickly, but with the data being displayed I want a 1/2 second to a second delay.

That's a very long program and a very short description of the problem. Can you provide more information so I don't have to try to reverse-engineer the program (which I am not prepared to do).

Have you tried writing a short program to figure out how to meet your objective before transferring the learning to the big program?

...R