条件一致判断をし所定の処理を行います。
Arduinoにおける文法は標準C言語と特に変わりはありません。
1 2 3 |
<strong>if (比較対象変数など) and ==, !=, <, > (比較先)</strong> <strong>● Example from Arduino Web Site</strong> |
[c]
if (someVariable > 50)
{
// do something here
}
[/c]
[c]
//if (x > 120) digitalWrite(LEDpin, HIGH);
if (x > 120)
digitalWrite(LEDpin, HIGH);
if (x > 120){ digitalWrite(LEDpin, HIGH); }
if (x > 120){
digitalWrite(LEDpin1, HIGH);
digitalWrite(LEDpin2, HIGH);
}
// all are correct
[/c]
()内で使われる比較演算子
[c]
x == y (x is equal to y)
x != y (x is not equal to y)
x < y (x is less than y)
x > y (x is greater than y)
x <= y (x is less than or equal to y)
x >= y (x is greater than or equal to y)
[/c]