Arduino-if-statement

提供:Dev Guides
移動先:案内検索

Arduino-Ifステートメント

括弧で囲まれた式と、ステートメントまたはステートメントのブロックを取ります。 式が真の場合、ステートメントまたはステートメントのブロックが実行されます。それ以外の場合、これらのステートメントはスキップされます。

ifステートメントのさまざまな形式

  • フォーム1 *
if (expression)
   statement;

ステートメントが1つある場合は、中括弧\ {}なしでifステートメントを使用できます。

  • フォーム2 *
if (expression) {
   Block of statements;
}

ifステートメント-実行シーケンス

IFステートメント

/*Global variable definition*/
int A = 5 ;
int B = 9 ;

Void setup () {

}

Void loop () {
  /*check the boolean condition*/
   if (A > B)/* if condition is true then execute the following statement*/
   A++;
  /*check the boolean condition*/
   If ( ( A < B ) && ( B != 0 ))/* if condition is true then execute the following statement*/{
      A += B;
      B--;
   }
}