Comparison operators

The Arduino programming language includes comparison operators that enable us to compare the values of two operands. The comparison operators return a Boolean value indicating if the comparison was true or false. The following code shows how we would use these operators:

x == y // returns true if x is equal to y
x != y // returns true if x is not equal to y
x > y // returns true if x is greater than y
x < y // returns true if x is less than y
x >= y // returns true if x is greater or equal to y
x <= y // returns true if x is less than or equal to y

Now that we have seen the comparison operators that the Arduino programming language provides, let's look at the logical operators.

Get Mastering Arduino now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.