Hi all, I just got a temperature and humidity sensor (si7021) and I'm trying to write a little code to have an LED go off at a certain temp or humid threshold. The LED just goes on all the time and I can see with the serial monitor that it's not adhering to the rule. Pretty new to programming Arduino so I'm sure my if statement is not right. Code is below, thanks!
And it still won't work as pin 8 was never declared as an output using pinMode(). The only thing that will happen is pin 8 will have an internal pullup attached.
Spacing an indentation don't matter to the way the compiler interprets your code.
if(foo);
id the same as
if(foo)
;
This is why I recommend that all if statements, while statements, etc. always use curly braces to define a statement list, even if there is only one statement.
if(sensor.readTemperature() > 30)
{
;
}
would stand out like a sore thumb as being clearly NOT what you wanted to do.