Arduino - Max6675 feedback issue

Hi Everyone,

There is a problem with max6675 feedback,i mean on the screen i cant see the temp. simultaneously i need to pust the button and renew it, otherwise i cant see the temp. i dont have any idea why.does anyone help me to fix my problem.

Here is the code''

''#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "max6675.h"

#define COOLDOWN_TIME 60 //60
#define PREHEAT_TIME 60
#define REFLOW_TIME 60

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

int thermoDO = 12;
int thermoCS = 13;
int thermoCLK = 14;

MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);

const int button = 2;
const int solidstate = 15;
const int poti = A0;

const int temp_preheat = 150;
const int temp_reflow = 241;

int temp_now = 0;
int temp_next = 0;
int temp_poti = 0;
int temp_poti_old = 0;
String state[] = {"OFF", "PREHEAT", "REFLOW", "COOLING"};
int state_now = 0;

int time_count = 0;
int perc = 0;

int offset = 0;

void setup() {
pinMode(button, INPUT);
pinMode(solidstate, OUTPUT);
digitalWrite(solidstate, LOW);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.display();
}

long t = millis();
long t_solder = millis();

void loop() {
temp_now = thermocouple.readCelsius();

temp_poti = map(analogRead(poti), 1023, 0, temp_preheat, temp_reflow);

if (temp_poti != temp_poti_old) {
int v = 0;
display.fillScreen(WHITE);
display.setTextColor(BLACK);
display.setTextSize(1);
display.setCursor(X(1, 7), Y(1, 0.1));
display.println("PREHEAT");
display.setTextSize(2);
display.setCursor(X(2, 3), Y(2, 0.5));
while (v < 100) {
temp_poti = map(analogRead(poti), 1023, 0, temp_preheat, temp_reflow);
if (temp_poti > temp_poti_old + 1 || temp_poti < temp_poti_old - 1) {
display.fillScreen(WHITE);
display.setTextSize(2);
display.setCursor(X(1, 19), Y(1, 0.1));
display.println("ERIME SIC.");
display.setTextSize(3);
display.setCursor(X(2, 5), Y(2, 0.5));
display.println(String(temp_poti)+(char)247);
display.display();
temp_poti_old = temp_poti;
v = 0;
}
v++;
delay(20);
}
temp_poti_old = temp_poti;
}

if (millis() > t + 200 || millis() < t) {
PrintScreen(state[state_now], temp_next, temp_now, time_count, perc);
t = millis();
}

if (digitalRead(button) == 0) {
delay(100);
int c = 0;
while (digitalRead(button) == 0) {
c++;
if (c > 150) {
digitalWrite(solidstate, LOW);
state_now = 0;
display.fillScreen(WHITE);
display.setTextColor(BLACK);
display.setTextSize(2);
display.setCursor(X(2, 3), Y(2, 0.5));
display.println("OFF");
display.display();
while (digitalRead(button) == 0) delay(1);
return;
}
delay(10);
}

t_solder = millis();
perc = 0,
state_now++;
if (state_now == 0) temp_next = 0;
else if (state_now == 1) temp_next = temp_preheat;
else if (state_now == 2) temp_next = temp_poti;
else if (state_now == 3) temp_next = 0;
else if (state_now == 4) {
  state_now = 0;
  temp_next = 0;
}

}

if (state_now == 1) { //PREHEAT
regulate_temp(temp_now, temp_next);

perc = int((float(temp_now) / float(temp_next)) * 100.00);

}
else if (state_now == 2) { //REFLOW
regulate_temp(temp_now, temp_next);

perc = int((float(temp_now) / float(temp_next)) * 100.00);
if (perc >= 100) {
  state_now = 3;
  t_solder = millis();
  perc = 0;
  temp_next = 0;
}

}
else if (state_now == 3) { //COOLING
digitalWrite(solidstate, LOW);

time_count = int((t_solder + COOLDOWN_TIME * 1000 - millis()) / 1000);
if (time_count <= 0) {
  state_now = 0;
}

}
else {
digitalWrite(solidstate, LOW);
time_count = 0;
}

delay(30);
}

void regulate_temp(int temp, int should) {
if (should <= temp - offset) {
digitalWrite(solidstate, LOW);
}
else if (should > temp + offset) {
digitalWrite(solidstate, HIGH);
}
}

void PrintScreen(String state, int soll_temp, int ist_temp, int tim, int percentage) {
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.println(state);

display.setCursor(95, 0);
String str = String(soll_temp)+(char)247+"C";
display.println(str);

if (tim != 0) {
display.setCursor(0, 50);
str = String(tim) + " sec";
display.println(str);
}

if (percentage != 0) {
display.setCursor(80, 50);
str = String(percentage) + " %";
display.println(str);
}

display.setTextSize(2.5);
display.setCursor(35, 22);
str = String(ist_temp) + (char)247 + "C";
display.println(str);

display.display();
}

int X(int textgroesse, int n) {
//gibt die X koordinate aus, damit text mit n zeichen mittig ist

return (0.5 * (display.width() - textgroesse * (6 * n - 1)));
}//end int X

int Y(int textgroesse, float f) {
//gibt die Y koordinate aus, damit text mittig ist

return (f * display.height() - (textgroesse * 4));
}//end int Y

''

Edit your post and insert code tags!

Change this line:

if (millis() > t + 200 || millis() < t) {

to

if (t - millis() > 200) {

I have some doubts that the posted code shows the temperature only if you push the button on pin 2.
Can you please explain in more detail what problem you have with that code?

Firstly thank you for your attention.I changed the code that you write,but still have the same problem.The temperature does not refresh on the screen. When I switch between the menus,by pushing with the butoon, the temperature changes. What I want is to be able to see the temperature momentarily.

Still no code tags! I refuse to further analyze the code without code tags and a correct formatting.