Arduino - if...else 語句



一個if語句可以跟隨著一個可選的else語句,當表示式為假時執行。

if...else 語句語法

if (expression) {
   Block of statements;
}
else {
   Block of statements;
}

if...else 語句 – 執行順序

If Else Statement

示例

/* 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++;
   }else {
      B -= A;
   }
}
arduino_control_statements.htm
廣告