Range within a range?

leogsd1:
Nooo, what i posted is just an example, I realize that the average can never go to 386....but what I am having a problem with it is that, Lets say average for 1 PM falls somewhere between 100 and 300. the average for 2 pm falls between 125 and 175. So when I try to simulate this, even though i get the value of say 150, it is showing 1 PM, when i need it to show 2 PM. Get it? its tricky to explain.

The code I posted, using your code and some serial prints, does what you say you want. If you don't want that, tell us what you DO want. Show an example of the output you want, if you can't say it in words.