This is an old revision of the document!
If is a statement that checks the condition and executes the following statements if the condition is true. There are multiple ways how to write down the if statement:
//1st example if (condition) statement; //2nd example if (condition) statement; //3rd example if (condition) { statement; } //4th example if (condition) { statement; }
if (condition) //condition should be a Boolean expression { //statement //executes when the condition is true }
if (x>10) { digitalWrite(LEDpin, HIGH) //statement is executed if the x>10 expression is true }
Logical operators are widely used together with the condition operator if that is described below.
There are multiple comparison operators used for comparing variables and values. Comparison operators are following:
The Boolean logical operators
Switch…case