run command if analog read is within 2 values

Hello All!

I need to run a command, only if an analog pin is giving a value within f.ex. 600 and 700, or else run another commando. How do i do this in the easiest way? (the else part i know…)

Use the && operator in your if statement.

if ( (condition1) && (condition2) )

So it would be valid if it was less than 700 AND greater than 600. If you're checking "levels" (0-100, 200-300, 300-400, etc.), you could manage with else ifs and a single condition.

To be clear, you need two conditions.

This will not work: “if (value > 100 && < 200)”.

Instead it must be: “if (value > 100) && (value < 200)”.

In the 2nd you are using two conditionals and ANDing their result.

Aha. Nice.

Thanks :D