  display.display();
  //Serial.print(millis());
  //Serial.print(" ");
- Serial.print(adc_copy);
+ //Serial.print(adc_copy);
  //  Serial.print("ADC_SAMPLE_WINDOW_PWM_DUTY");
  // Serial.println(ADC_SAMPLE_WINDOW_PWM_DUTY);
  //Serial.print(" ");

 
 //convert to degrees C
 temperature_copy=ADS1118_INT_TEMP_C(temperature_copy);
 
 
 //Serial.print(temperature_copy);
 //Serial.print(" ");
 //Serial.println(adc_copy);


///////////////
   display.clearDisplay();

  // interpolate in the right segment for the rest
  return (val - _in[pos-1]) * (_out[pos] - _out[pos-1]) / (_in[pos] - _in[pos-1]) + _out[pos-1];
}

//this function sends all of our status values as a hex string. this reduces the CPU load on the MCU since it doesnt have to format float strings.
void SendStatusPacket()
{
  controller_packet.status.start_of_packet = 0xBA;
  controller_packet.status.setpoint = Setpoint;
  noInterrupts(); //make sure we disable interrupts while grabing these volatile values.
  controller_packet.status.input = Input;
  controller_packet.status.output = Output;
  controller_packet.status.ITerm = myPID.GetITerm();
  interrupts();
  controller_packet.status.kP = myPID.GetKp();
  controller_packet.status.kI = myPID.GetKi();
  controller_packet.status.kD = myPID.GetKd();
  controller_packet.status.automatic = (myPID.GetMode()==AUTOMATIC);
  int i;
  for (i=0;i<sizeof(controller_packet_converter);i++)
  {
     const char lookup[] = "0123456789abcdef";
     Serial.write(lookup[ controller_packet.asBytes[i] >> 4 ]);
     Serial.write(lookup[ controller_packet.asBytes[i] & 0x0f ]);
  }
  Serial.write('\n');
}

//Receive commands from the tuning PC app
void SerialReceive()
{

  // read the bytes sent from tuning app
  int index=0;
  //if there are bytes in the serial buffer, then read them until we have received a full packet
  while(Serial.available()&&index<sizeof(host_packet_converter))
  {
   host_packet.asBytes[index]=Serial.read();
   index++;
  } 

  //when there are no more bytes to read, check if we read the correct number of bytes and make sure our first byte equals our hard-coded start of packet value
  if(index==sizeof(host_packet_converter) && host_packet.param.start_of_packet==0xAB)
  {
    //update PID settings
    Setpoint=host_packet.param.setpoint;
    //Input=host_packet.param.input;
    //only change the outpput if we are in manual mode
    if(host_packet.param.automatic==0)    
    {                                     
      Output=host_packet.param.output;    
      myPID.SetMode(MANUAL);              
    }
    else
    {
      myPID.SetMode(AUTOMATIC);              
    }
    //update the gains
    myPID.SetTunings(host_packet.param.kP, host_packet.param.kI, host_packet.param.kD);            // Set PID tunings  
  }
  Serial.flush();                         // * clear any random data from the serial buffer
}
