Just about if-else, and one tip -- while coding use the AutoFormat tool (ctrl-t) often as it checks syntax. It's easier to keep code straight a little at a time than write up a load of code and then start debugging all the problems at once.
if(tempC>=21)
{
digitalWrite(LED_BUILTIN, HIGH);
}
else if(tempC<=20)
{
digitalWrite(LED_BUILTIN, HIGH); // so no change?
}
Your code has no hole but the if(tempC<=20) isn't needed since everything not >= 21 must be < 21 (<= 20).
The compiler very likely does not code the second if().
Practice pruning and it won't be long before you won't have to... much.. you will be able to read code much easier.
The else if is for when you want to chain if()'s.
Here the if-else-if-else... chain slices possible values for tempC from the top down. Once everything >= 21 are taken, everything >= 18 can only be 18, 19 or 20. Every cut[/] takes away from what's left and the last else gets that.
Here's the routine in pseudo-snippet:
```
- if(tempC>=21)
{
digitalWrite(LED_BUILTIN, HIGH);
}
else if(tempC >= 18)
{
mySoftPWMfunction(LED_BUILTIN, 190);
}
else if(tempC >= 15)
{
mySoftPWMfunction(LED_BUILTIN, 127);
}
else if(tempC >= 12)
{
mySoftPWMfunction(LED_BUILTIN, 63);
}
else
{
digitalWrite(LED_BUILTIN, LOW);
}*
```