I'm implementing a program which control the temperature to a an Adjusted value using (+ and -) drawn arrows.
In the loop function, I'm measuring tempreature every 3 seconds (delay 3 seconds). However, when I try to increase the adjusted tempreature using " + and -" , the value increase by one degree after 3 seconds.
I just need the interrupt function, so that when " + and - " are pushed, the value increase or decreases immediately without waiting for the delay.
As could be seen from the screen, I didn't found an interrupt pin to do so. Even I assumed that pin 2 is the interrupt pin, does that mean than once the TFT screen is touched, the interrupt function would work ?
Well, as you mentioned, updating the temperature causes a continuous blink, so I tried to control this by the following code :
void loop() {
AdjustTemp ();
tempC = analogRead(tempPin); // read the analog value from the lm35 sensor.
tempC = (5.0 * tempC * 100.0)/1024.0; // convert the analog input to temperature in centigrade.
OldTemp=int(tempC); // Read the temperature 1
delay(3000);
tempC = analogRead(tempPin); // read the analog value from the lm35 sensor.
tempC = (5.0 * tempC * 100.0)/1024.0; // convert the analog input to temperature in centigrade. NewTemp=tempC;
NewTemp=int(tempC); // Read temperature 2
if (NewTemp!=OldTemp) { // Compare temperature 1 and temperature 2 , if not equal
myGLCD.setColor(16, 167, 103); // set green colour
myGLCD.fillRoundRect (5, 135, 150, 175); // draw a rectangle within these dimensions
myGLCD.setFont(BigFont); // Select big font
myGLCD.setColor(255, 255, 255); // select white color
myGLCD.print("° C", 100, 150); // Print " C " sympol
myGLCD.printNumI(tempC,45, 150); // Update temperature
}
}
If I removed this condition , temperature reading will be taken continuously, and the area where the temperature value is inserted will blink continuously that's why I wrote a " delay " line.
Without delay function, the temperature is updated within milliseconds, and it shows continuous variations,
with the delay function, variation are much less.
Is there another idea to prevent such a blink without delay function ?
What "condition"? delay() isn't a "condition". It's a disease.
Is there another idea to prevent such a blink without delay function ?
Why would you want to prevent "without delay"?
It does not matter how often you get the new setpoint from the TFT. It does not matter how often you read the temperature.
The LCD issues are because you are writing too often. Read, understand, and embrace the philosophy of the blink without delay example. While that example's primary goal is to change the state of the pin every time the time is right, and your goal is to write to the LCD when the time is right, it ought to be perfectly obvious what code from the example to remove, and what part of your code should go in it's place.