Temp sensor not reading unless timer is active

please assist me, my temp sensor is only reading when the timer is active or i am busy setting the timer please assist**#include <Wire.h>
#include <max6675.h>
#include<LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16,2); // Set the LCD I2C address

#define Start 4 // start stop button
#define COOKER 13
int thermoDO = 8;
int thermoCS = 5;
int thermoCLK = 7;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
uint8_t degree[8] = {140, 146, 146, 140, 128, 128, 128, 128};
int hours = 0;
int minutes = 0;
int seconds = 0;
boolean timeState = false;
#define encoderPinA 2 // right
#define encoderPinB 3 // left
#define encoderButton 6 // switch
#define gnd2 12
#define vcc2 11
#define gnd3 10
int HMS = 1;
int encoderPos = 0; // a counter for the dial
unsigned int lastReportedPos = 1; // change management
static boolean rotating = false; // debounce management
boolean A_set = false;
boolean B_set = false;

void setup() {
pinMode(COOKER, OUTPUT);
digitalWrite(COOKER , HIGH);
pinMode (vcc2 , OUTPUT);
digitalWrite(vcc2, HIGH);
pinMode(gnd3, OUTPUT);
digitalWrite(gnd3, LOW);
pinMode (gnd2 , OUTPUT);
digitalWrite(gnd2 , LOW);
pinMode(Start, INPUT_PULLUP);
pinMode(encoderPinA, INPUT_PULLUP); //enabling pullups
pinMode(encoderPinB, INPUT_PULLUP);
pinMode(encoderButton, INPUT_PULLUP);
attachInterrupt(0, doEncoderA, CHANGE); //pin 2
attachInterrupt(1, doEncoderB, CHANGE); //pin 3
Serial.begin(9600); // output
lcd.init(); // initialize the lcd for 16 chars 2 lines, turn on backlight
lcd.setBacklight(HIGH);
lcd.clear();
lcd.setCursor(0, 0);
lcd.setCursor(0, 0);
lcd.print (“COOKER”);
lcd.setCursor(4, 1);
lcd.print(“00:00:00”);
lcd.setCursor(15, 0);
lcd.print(“C”);

}

void loop() {
lcd.setCursor(7, 0);
lcd.print( thermocouple.readCelsius(), 2);
Serial.print(thermocouple.readCelsius());

if (digitalRead(encoderButton) == LOW)
{
HMS = HMS + 1;
if (HMS == 4)
{
HMS = 1;
}
delay(1000);
}
rotating = true; // reset the debouncer
encoderPos = constrain(encoderPos, -1, 1);
if (lastReportedPos != encoderPos) {

if (HMS == 1) {
  hours = hours + encoderPos;
  hours = constrain(hours, 0, 48);
}
else if (HMS == 2) {
  minutes = minutes + encoderPos;
  minutes = constrain(minutes, 0, 60);
}
else if (HMS == 3) {
  seconds = seconds + encoderPos;
  seconds = constrain(seconds, 0, 60);
}
// Serial.println(encoderPos); // for testing
// Serial.print("hours ");
// Serial.println(hours);
// Serial.print("minutes ");
// Serial.println(minutes);
// Serial.print("seconds ");
// Serial.println(seconds);
// Serial.println(" ");
lcd.setCursor(4, 1);
if (hours <= 9)
{
  lcd.print("0");
}
lcd.print(hours);
lcd.print(":");
if (minutes <= 9)
{
  lcd.print("0");
}
lcd.print(minutes);
lcd.print(":");
if (seconds <= 9)
{
  lcd.print("0");
}
lcd.print(seconds);
encoderPos = 0;
lastReportedPos = encoderPos;

}
if (thermocouple.readCelsius() > 38.00 ) { //start count down timer
timeState = true;
//delay(1000);
while (timeState == true) {
if (minutes == 0 && hours >= 1) {
minutes = 60;
hours = hours - 1;
}
if (seconds == 0 && minutes >= 1) {
seconds = 60;
minutes = minutes - 1;
}
else if (minutes == 0 && hours == 0 && seconds == 0) { //count down alarm
while (timeState == true) {
tone(11, 600, 250);
delay(250);
tone(11, 800, 250);
delay(250);

    }
  }
  delay(992); // delay for keping time master setting!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  seconds = seconds - 1;
  //Serial.print("hours "); // for testing
  //Serial.println(hours);
  //Serial.print("minutes ");
  //Serial.println(minutes);
  //Serial.print("seconds ");
  // Serial.println(seconds);
  //Serial.println(" ");

  lcd.setCursor(4, 1);
  if (hours <= 9)
  {
    lcd.print("0");
  }
  lcd.print(hours);
  lcd.print(":");
  if (minutes <= 9)
  {
    lcd.print("0");
  }
  lcd.print(minutes);
  lcd.print(":");
  if (seconds <= 9)
  {
    lcd.print("0");
  }
  lcd.print(seconds);

  if (digitalRead(Start) == LOW) {
    delay(1000);
    timeState = false;
    break;
  }
}

}

}

// Interrupt on A changing state
void doEncoderA() {
// debounce
if ( rotating ) delay (1); // wait a little until the bouncing is done

// Test transition, did things really change?
if ( digitalRead(encoderPinA) != A_set ) { // debounce once more
A_set = !A_set;

// adjust counter + if A leads B
if ( A_set && !B_set )
  encoderPos = 1;

rotating = false; // no more debouncing until loop() hits again

}
}

// Interrupt on B changing state
void doEncoderB() {
if ( rotating ) delay (1);
if ( digitalRead(encoderPinB) != B_set ) {
B_set = !B_set;
// adjust counter - 1 if B leads A
if ( B_set && !A_set )
encoderPos = -1;

rotating = false;

}
}**

Please Auto format your code in the IDE, select all of it, use Copy for forum in the IDE and paste it here so that it is code tags to make it easier to read and copy for examination

what i need is for it to monitor the temp and start the countdown when it gets to a set point

#include <Wire.h>
#include <max6675.h>
#include<LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address

#define Start 4 // start stop button
#define COOKER  13
int thermoDO = 8;
int thermoCS = 5;
int thermoCLK = 7;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
uint8_t degree[8]  = {140, 146, 146, 140, 128, 128, 128, 128};
int hours = 0;
int minutes = 0;
int seconds = 0;
boolean timeState = false;
#define encoderPinA 2 // right
#define encoderPinB 3 // left
#define encoderButton 6 // switch
#define gnd2 12
#define vcc2 11
#define gnd3 10
int HMS = 1;
int encoderPos = 0; // a counter for the dial
unsigned int lastReportedPos = 1; // change management
static boolean rotating = false; // debounce management
boolean A_set = false;
boolean B_set = false;


void setup() {
  pinMode(COOKER, OUTPUT);
  digitalWrite(COOKER , HIGH);
  pinMode (vcc2 , OUTPUT);
  digitalWrite(vcc2, HIGH);
  pinMode(gnd3, OUTPUT);
  digitalWrite(gnd3, LOW);
  pinMode (gnd2 , OUTPUT);
  digitalWrite(gnd2 , LOW);
  pinMode(Start, INPUT_PULLUP);
  pinMode(encoderPinA, INPUT_PULLUP); //enabling pullups
  pinMode(encoderPinB, INPUT_PULLUP);
  pinMode(encoderButton, INPUT_PULLUP);
  attachInterrupt(0, doEncoderA, CHANGE); //pin 2
  attachInterrupt(1, doEncoderB, CHANGE); //pin 3
  Serial.begin(9600); // output
  lcd.init(); // initialize the lcd for 16 chars 2 lines, turn on backlight
  lcd.setBacklight(HIGH);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.setCursor(0, 0);
  lcd.print ("COOKER");
  lcd.setCursor(4, 1);
  lcd.print("00:00:00");
  lcd.setCursor(15, 0);
  lcd.print("C");

}

void loop() {
  lcd.setCursor(7, 0);
  lcd.print( thermocouple.readCelsius(), 2);
  Serial.print(thermocouple.readCelsius());


  if (digitalRead(encoderButton) == LOW)
  {
    HMS = HMS + 1;
    if (HMS == 4)
    {
      HMS = 1;
    }
    delay(1000);
  }
  rotating = true; // reset the debouncer
  encoderPos = constrain(encoderPos, -1, 1);
  if (lastReportedPos != encoderPos) {

    if (HMS == 1) {
      hours = hours + encoderPos;
      hours = constrain(hours, 0, 48);
    }
    else if (HMS == 2) {
      minutes = minutes + encoderPos;
      minutes = constrain(minutes, 0, 60);
    }
    else if (HMS == 3) {
      seconds = seconds + encoderPos;
      seconds = constrain(seconds, 0, 60);
    }
    // Serial.println(encoderPos); // for testing
    // Serial.print("hours ");
    // Serial.println(hours);
    // Serial.print("minutes ");
    // Serial.println(minutes);
    // Serial.print("seconds ");
    // Serial.println(seconds);
    // Serial.println(" ");
    lcd.setCursor(4, 1);
    if (hours <= 9)
    {
      lcd.print("0");
    }
    lcd.print(hours);
    lcd.print(":");
    if (minutes <= 9)
    {
      lcd.print("0");
    }
    lcd.print(minutes);
    lcd.print(":");
    if (seconds <= 9)
    {
      lcd.print("0");
    }
    lcd.print(seconds);
    encoderPos = 0;
    lastReportedPos = encoderPos;

  }
  if (thermocouple.readCelsius() > 38.00 ) { //start count down timer
    timeState = true;
    //delay(1000);
    while (timeState == true) {
      if (minutes == 0 && hours >= 1) {
        minutes = 60;
        hours = hours - 1;
      }
      if (seconds == 0 && minutes >= 1) {
        seconds = 60;
        minutes = minutes - 1;
      }
      else if (minutes == 0 && hours == 0 && seconds == 0) { //count down alarm
        while (timeState == true) {
          tone(11, 600, 250);
          delay(250);
          tone(11, 800, 250);
          delay(250);

        }
      }
      delay(992); // delay for keping time master setting!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      seconds = seconds - 1;
      //Serial.print("hours "); // for testing
      //Serial.println(hours);
      //Serial.print("minutes ");
      //Serial.println(minutes);
      //Serial.print("seconds ");
      // Serial.println(seconds);
      //Serial.println(" ");

      lcd.setCursor(4, 1);
      if (hours <= 9)
      {
        lcd.print("0");
      }
      lcd.print(hours);
      lcd.print(":");
      if (minutes <= 9)
      {
        lcd.print("0");
      }
      lcd.print(minutes);
      lcd.print(":");
      if (seconds <= 9)
      {
        lcd.print("0");
      }
      lcd.print(seconds);

      if (digitalRead(Start) == LOW) {
        delay(1000);
        timeState = false;
        break;
      }
    }
  }

}

// Interrupt on A changing state
void doEncoderA() {
  // debounce
  if ( rotating ) delay (1); // wait a little until the bouncing is done

  // Test transition, did things really change?
  if ( digitalRead(encoderPinA) != A_set ) { // debounce once more
    A_set = !A_set;

    // adjust counter + if A leads B
    if ( A_set && !B_set )
      encoderPos = 1;

    rotating = false; // no more debouncing until loop() hits again
  }
}

// Interrupt on B changing state
void doEncoderB() {
  if ( rotating ) delay (1);
  if ( digitalRead(encoderPinB) != B_set ) {
    B_set = !B_set;
    // adjust counter - 1 if B leads A
    if ( B_set && !A_set )
      encoderPos = -1;

    rotating = false;
  }
}

Thank you - the easier you make it to read and copy the code the more likely it is that you will get help

no thank you for understanding i am battling to get used to this new forum

Hello
desribe in simple words what your sketch shall do and do it very simple.

It must countrol a pressure cooker for a specific time and the timer needs to start when it gets to a specific temp

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.