I'm looking for an example of an analog state change detection. So for example, if I'm tracking temperature on an analog pin how can I send the data over the radio only if there is a change in temperature. This will cut down on radio traffic
Quote from: djash40 on February 16, 2016, 04:25:59 PM
I'm looking for an example of an analog state change detection. So for example, if I'm tracking temperature on an analog pin how can I send the data over the radio only if there is a change in temperature. This will cut down on radio traffic
Do you want something more sophisticated than:
...
newValue = readAnalogSensor();
if (newValue != oldValue)
{
radio.send...
oldValue = newValue;
}
...
If so, you need to be much more specific about what you want.
Tom
So I need to take all my existing variables that I want to track and make a new one to compare if there is a difference.
Is that correct?
Thanks Tom.
Quote from: djash40 on February 16, 2016, 04:57:45 PM
So I need to take all my existing variables that I want to track and make a new one to compare if there is a difference.
Is that correct?
Thanks Tom.
Yes, if you want to use this method.
A more generalized approach would be to use an array to save the oldValues and then, as you read each new one, just compare it to oldValues
and, if the newValue is different, simply store it in oldValue
Then, increment i for each value you check.
Tom