comparison of current value and previous value (thermistor temp readings)

Hi, this is my first time posting on this forum. I've got a bit of an issue on an assignment and any help would be greatly appreciated. I am using an arduino mega 2560, breadboard, ntc 10k thermistor, breadboard, and a resistor.
Problem:
I need to record the temperature of the thermistor every second. I've already achieved that so far (code is based on adafruit website), but now I want to show the temperature reading on the serial monitor only IF my temperature has gone up or down by 0.50 degrees Celsius. For example, if temperature reading went up from 23 to 23.50 then it will show 23.50 on the serial monitor, if the temperature went up from 23 to 23.22, there will no new value updated to the serial monitor
I've tried a writing a few if and else statements but nothing seems to be working.
Attached is the code I have so far.
Thank you in advance.

lab5.4.ino (2.04 KB)

So if the temperature was 23 then goes up to 23.22 your next notification would be 23.72?

I've tried a writing a few if and else statements

But you forgot to show any of those efforts.

The code specification is incomplete, but this might give some ideas:

if ( fabs (current_temp - last_temp) >= 0.5) { //float values assumed
display(current_temp);
}
last_temp = current_temp;

You will discover problems with this simplistic approach (as your assignment is described).

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