Arduino - If… else statement

Un if può essere seguita da un'istruzione else opzionale, che viene eseguita quando l'espressione è falsa.

if ... else Sintassi dell'istruzione

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

Istruzione if ... else - Sequenza di esecuzione

Esempio

/* 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;
   }
}