tft problem refresh

hello everyone i have one big problem and i try to fix 10 days now but with no effect.
i want to see the temperature from lm35 to tft 1.8'' all good but my problem is after refresh the numbers at tft from lm is flashing if the delay is small about 250ms flashing is all the time only the numbers of temperature i try to fix but the flashing of temperature is there and i hate this cant you tell what is the wrong of my code and what chanse i do to fix this flashing??
Thanks a lot.

// Arduino LCD library
#include <TFT.h> 
#include <SPI.h>
// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
const int water_Pin = A0;
const int oil_Pin = A2;
const int LED_Pin = 2;
const int threshold = 316;
int Input_Value = 0;
 
// char array to print to the screen
char sensorwater[4];
char sensoroil[4];

void setup() {
analogReference(INTERNAL);
pinMode(2, OUTPUT);
// Put this line at the beginning of every sketch that uses the GLCD:
TFTscreen.begin();
// clear the screen with a black background
TFTscreen.background(0, 0, 0);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255, 255, 255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("Water Temp\n " , 25 ,0);
TFTscreen.text("C", 95, 20);
TFTscreen.text("Oil Temp\n" ,35 ,60);
TFTscreen.text("C", 95, 80);
// ste the font size very large for the loop
TFTscreen.setTextSize(5);
}

void loop() {
// print the sensor value
String water = String(analogRead(A0)*1.1*100/1024);
String oil = String(analogRead(A2)*1.1*100/1024);
water.toCharArray(sensorwater, 4);
oil.toCharArray(sensoroil, 4);

TFTscreen.stroke(255, 255, 255);
TFTscreen.text(sensoroil, 0, 80);  
TFTscreen.text(sensorwater, 0, 20);  
  
delay (250);   

TFTscreen.stroke(0, 0, 0);
TFTscreen.text(sensoroil, 0, 80);  
TFTscreen.text(sensorwater, 0, 20);
}

Could you please punctuate your run-on sentence so we can understand it?

Why waste memory with Strings? Please use char* instead.

To fix your flashing issue, you need to only update the display (or at least that line of text) only when the value has changed.

Text is white: TFTscreen.stroke(255, 255, 255);
delay (250);
Text is black: TFTscreen.stroke(0, 0, 0);

Hazard now i lern arduino this is the firt project and from athrore projects i see the strings and this i use i dont see and i dont now how to use char but i look my problem with flashing i want to fix and them i fixs and the strings :slight_smile: what chance what to do at code to update only the display only when the value has changed?
if after dealy i remove the TFTscreen.stroke(0, 0, 0); the flashing not exist but the numbers ar stuck :confused:

Try this for your loop. (untested)

void loop() {
  // print the sensor value
  static unsigned long last_w, last_o; // these are static so they will not be remade every loop.
  
  unsigned long water = calculate(water_Pin);
  unsigned long oil = calculate(oil_Pin);
  char buffer[10];
  memset(buffer, 0, sizeof(buffer));
  
  if (water != last_w) // only true if the value has changed.
  {
    last_w = water;
    sprintf(buffer, "%ld", water); // convert the value of water to a string
    TFTscreen.stroke(0, 0, 0); // set black
    TFTscreen.text("     ", 0, 20); // clear that space
    TFTscreen.stroke(255, 255, 255); // set white
    TFTscreen.text(buffer, 0, 20); // print text
  }
  
 // same as above
  if (oil != last_o)
  {
    last_o = oil;
    sprintf(buffer, "%ld", oil);
    TFTscreen.stroke(0, 0, 0);
    TFTscreen.text("     ", 0, 20);
    TFTscreen.stroke(255, 255, 255);
    TFTscreen.text(buffer, 0, 20);
  }
}

unsigned long calculate(byte pin)
{
  return (analogRead(pin) * 1.1f * 0.09765f); // I don't know if you want the final value as a float or not
}

ok the problem is fix ty my friend HazardsMind :smiley:
pls locked.