Professional Documents
Culture Documents
Relational Operators in Arduino
Relational Operators in Arduino
Relational Operators in Arduino
Equal to (==): CHecks if two values are equal and returns true if they are, false otherwise
Exp: if (a==b){…}
int a = 5;
int b = 5;
Not equal to (!=): Checks if two values are not equal and returns true if they are not, false otherwise
Exp : if (a!=b){…}
int a = 5;
int b = 10;
Greater than (>): Checks if the left operand is greater than the right operand and returns true if it is,
false otherwise.
Exp: if (a>b){…}
int a = 10;
int b = 5;
Less than or equal to (<=): Checks if the left operand is less than or equal to the right operand and
returns true if it is, false if otherwise.
Exp: if (a<=b){…}
int a = 5; or int a = 1;
int b = 10
///////////////////////////////////////////////////////////////////////////////////////////////////////////
The “%” operator in Arduino (and in many programming languages) is the modulus operator.
Int a = 17;
Int b = 5;
Int c = 2;
Int result1 = a % b; // result will be 2
Int result2 = a % c; // result will be 1