plx daq and lcd keypad

hi guys

i want to ask about my project. I use uno for controling and monitoring HVAC system, i use lcd keypad shield for setting the setpoint temperature and differential, and I use PLX-daq to send data from 4 ds18b20 temp sensor.
I want to send temperature data in every 30sec to the excel, but when i set delay(30000)in the program, the keypad (LCD-keypad) doesnt work, and i cant regulate the setpoint from the keypad (LCD-keypad shield). anyone can help me about the program please?? im beginner user.

thanks,,
best regards,

this is the code;

#include <stdio.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS_PIN 3
OneWire oneWire(ONE_WIRE_BUS_PIN);
DallasTemperature sensors(&oneWire);

#include <LiquidCrystal.h>

#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define NUM_KEYS   5


const int relay = 13;  
float temp,temp0,temp1,temp2;  
int settemp = 29;  
int diff = 4;
int cutin;
int cutout;
int keyEvent  = -1;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); 

void setup() {

  pinMode(relay, OUTPUT);  
  Serial.begin(9600); 
  lcd.begin(16, 2); 
lcd.setCursor(8,0);
         lcd.print("Diff:");
         lcd.print(diff);
         lcd.setCursor(0,0);
            sensors.requestTemperatures();
   temp  = sensors.getTempCByIndex(0); 
    lcd.print("Set:");
  lcd.print(settemp);  
  Serial.println("CLEARDATA");
Serial.println("LABEL,Time,Temperature1,Temperature2,Temperature3,Temperature4");
}

void plx()
{
  
    sensors.requestTemperatures();
    temp0 = sensors.getTempCByIndex(1); 
    temp1 = sensors.getTempCByIndex(2);
    temp2 = sensors.getTempCByIndex(3);
    temp  = sensors.getTempCByIndex(0); 
    
   Serial.print("DATA,");
   Serial.print("TIME,");
   Serial.print(temp);Serial.print(",");
   Serial.print(temp0);Serial.print(",");
   Serial.print(temp1);Serial.print(","); 
   Serial.print(temp2);Serial.print(",");

  Serial.println(temp);
  temp++;
  Serial.println(temp0);
  temp0++;
  Serial.println(temp1);
  temp1++;
  Serial.println(temp2);
  temp2++;

delay(30000);

}
  

void loop() 
{ 
  
  plx();
   
cutout=(settemp-(diff/2));
cutin=(settemp+(diff/2));
    
lcd.setCursor(0,0);
    lcd.print("Set:");              
    lcd.print(settemp);    
    lcd.setCursor(8,0);
    lcd.print("Diff:");
    lcd.print(diff);     
    lcd.setCursor(0,1); 
    lcd.print("Cabin:");     
    lcd.print(temp);                   
                     
           

  if (temp > cutin) 
  {
    digitalWrite(relay, HIGH);
  }  
  if (temp <= cutout)

  {
    digitalWrite(relay, LOW);
  }
  int keyEvent = detectKey();
  if (keyEvent>=0)
    switch (keyEvent)               
    {
    case btnRIGHT:
      {
        diff  = (diff + 1);
         lcd.clear();
        break;
      }
    case btnLEFT:
      {  
        diff  = (diff - 1);
        lcd.clear(); 
        break;
      }
    case btnUP:
      {
        settemp  = (settemp + 1);            
    lcd.clear(); 
        break;
      }
    case btnDOWN:
      {
        settemp = (settemp - 1);             
    lcd.clear(); 
        break;
      }}}
    

int adc_key_val[NUM_KEYS] ={ 50, 195, 380, 555, 760};
int get_key(unsigned int input)
{
    int k;
    for (k = 0; k < NUM_KEYS; k++)
    {
        if (input < adc_key_val[k])
            return k;
    }
    if (k >= NUM_KEYS)
        k = -1; // No valid key pressed
    return k;
}

// ===================================================================
// new key detection routine, without delays!

int     lastKeyEvent = 0;
int     curKeyEvent  = 0;
int     keyToReturn  = 0;
boolean keyToProcess = false;
int     adc_key_in   = 0;

int detectKey()
{
    keyToReturn = -1;
    adc_key_in = analogRead(0);         // read the value from the sensor  
    curKeyEvent = get_key(adc_key_in);      // convert into key press
    if (curKeyEvent != lastKeyEvent)
    {
        if (!keyToProcess) 
        {
            lastKeyEvent = curKeyEvent;
            keyToProcess = true;
        }
        else
        {
            keyToReturn = lastKeyEvent;
            lastKeyEvent = -1;
            keyToProcess = false;
        }
    }
    return keyToReturn;
}

// ===================================================================

Read this from Robin2 work on Demonstration code for several things at the same time, to replace your delay(30000) in the program
http://forum.arduino.cc/index.php?topic=223286.0

okk BillHo, thanks for your assistance

this is my new code i;ve combine with blink without delay code :slight_smile:

#include <stdio.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS_PIN 3
OneWire oneWire(ONE_WIRE_BUS_PIN);
DallasTemperature sensors(&oneWire);

#include <LiquidCrystal.h>

#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define NUM_KEYS 5

int ledState = LOW;
long previousMillis = 0;

long interval = 15000;

const int relay = 13;
float temp,temp0,temp1,temp2;
int settemp = 29;
int diff = 4;
int cutin;
int cutout;
int keyEvent = -1;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {

pinMode(relay, OUTPUT);
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(8,0);
lcd.print("Diff:");
lcd.print(diff);
lcd.setCursor(0,0);
sensors.requestTemperatures();
temp = sensors.getTempCByIndex(0);
lcd.print("Set:");
lcd.print(settemp);
Serial.println("CLEARDATA");
Serial.println("LABEL,Time,Temperature1,Temperature2,Temperature3,Temperature4");
}

void plx()
{
Serial.print("DATA,");
Serial.print("TIME,");
Serial.print(temp);Serial.print(",");
Serial.print(temp0);Serial.print(",");
Serial.print(temp1);Serial.print(",");
Serial.print(temp2);Serial.print(",");

Serial.println(temp);
temp++;
Serial.println(temp0);
temp0++;
Serial.println(temp1);
temp1++;
Serial.println(temp2);
temp2++;

}

void loop()
{

unsigned long currentMillis = millis();

if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;

if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
if (ledState == LOW)
{ledState = HIGH;
plx();}

else
ledState = LOW;

}

sensors.requestTemperatures();
temp = sensors.getTempCByIndex(0);
temp0 = sensors.getTempCByIndex(1);
temp1 = sensors.getTempCByIndex(2);
temp2 = sensors.getTempCByIndex(3);
temp = sensors.getTempCByIndex(0);

cutout=(settemp-(diff/2));
cutin=(settemp+(diff/2));

lcd.setCursor(0,0);
lcd.print("Set:");
lcd.print(settemp);
lcd.setCursor(8,0);
lcd.print("Diff:");
lcd.print(diff);
lcd.setCursor(0,1);
lcd.print("Cabin:");
lcd.print(temp);

if (temp > cutin)
{
digitalWrite(relay, HIGH);
}
if (temp <= cutout)

{
digitalWrite(relay, LOW);
}
int keyEvent = detectKey();
if (keyEvent>=0)
switch (keyEvent)
{
case btnRIGHT:
{
diff = (diff + 1);
lcd.clear();
break;
}
case btnLEFT:
{
diff = (diff - 1);
lcd.clear();
break;
}
case btnUP:
{
settemp = (settemp + 1);
lcd.clear();
break;
}
case btnDOWN:
{
settemp = (settemp - 1);
lcd.clear();
break;
}}}

int adc_key_val[NUM_KEYS] ={ 50, 195, 380, 555, 760};
int get_key(unsigned int input)
{
int k;
for (k = 0; k < NUM_KEYS; k++)
{
if (input < adc_key_val[k])
return k;
}
if (k >= NUM_KEYS)
k = -1; // No valid key pressed
return k;
}

// ===================================================================
// new key detection routine, without delays!

int lastKeyEvent = 0;
int curKeyEvent = 0;
int keyToReturn = 0;
boolean keyToProcess = false;
int adc_key_in = 0;

int detectKey()
{
keyToReturn = -1;
adc_key_in = analogRead(0); // read the value from the sensor
curKeyEvent = get_key(adc_key_in); // convert into key press
if (curKeyEvent != lastKeyEvent)
{
if (!keyToProcess)
{
lastKeyEvent = curKeyEvent;
keyToProcess = true;
}
else
{
keyToReturn = lastKeyEvent;
lastKeyEvent = -1;
keyToProcess = false;
}
}
return keyToReturn;
}

// ===================================================================