I am writing a program that obtains a temperature from a thermistor and then needs to determine what temperature range it falls in to then turn on a specific coloured LED. The issue I am having is that when the temperature falls in a certain range, more than one light turns on and I only want one of the 3 from an RGB LED.
Right now, my if statement to check the value of the temperature is:
if (-40.0 < tempValue && tempValue < 20.5)
{
//turn blue light on
}
else if (20.5 < tempValue && tempValue < 37.3)
{
//turn green light on
}
etc... where tempValue is the temperature obtained from the thermistor.
After reading a bunch of posts about floats and comparing them/equality statements, I know that there is definitely an issue in doing so the "regular" way of comparing, but I am not sure how else to check the temperature based on a given range with a max and min value.