I'm working on a project where I'm taking temperature sensor readings and displaying them on an OLED screen. I've worked out how to get the current temperature reading from the sensor I'm trying to work out how I can get the arduino to watch that current reading and retain the highest number and display that on another line.
In short: I'm looking for the coding needed for the arduino to read that sensor and remember the highest number WITHOUT stopping the current reading from being able to be displayed.
"So are you saying I'm over thinking this? My desired outcome is to display both current and the highest."
Maybe you are under thinking it.
Did you consider what time frame?
Should the display indicate the highest temp. since the last sunrise, or in the last hour, or for ever or ....
Why only go half way? If you will display the current temp, and the highest temp., then why not go the extra mile, and also display the lowest temp.
Are you asking for the line of code to do this? We will be glad to help you, but rather that you think about it, and tell us what you think would work, then we will make suggestions to improve it.
If you have code that is working (read sensor, and display temp.), please show it to us (use the code tag, first icon on the top left of the entry screen).
AWOL:
You'd write it down, and if a higher value came up, you'd rub out the current highest, and overwrite it.
That's where I can't work out how to keep the the "high" number from being overwritten like the live numbers.
In an effort to simplify things I'm just working on the time since the arduino has been switched on - while I like your idea of having more data I'm still stuck on getting 1 piece.
Sounds like you need two numbers (variables), highTemp, and currentTemp.
It is ok to overwrite the numbers on the OLED. For instance, the highTemp may overwrite the same number for many display updates (you probably will not even be able to see it blink).
to set the variable, highTemp, your code (script) should change highTemp if currentTemp is higher than the previous highTemp.
You can read the temp sensor every once in a while (maybe ever 2 seconds?), and update your display ever once in a while (maybe ever 2 seconds?).
Have you got code that is working now? Please show us. (inside the code tags </> icon)
I was fighting with trying to re-write the variable of highTemp over and over again from the currentTemp number instead of addressing it on my own.
I will work the code a little now that I have another idea and post it when I get to my computer at home and THANK YOU