O'Reilly logo

Mastering Arduino by Jon Hoffman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Logical operators

There are several logical operators included in the Arduino programming language. These operators are the AND, OR and NOT operators. The NOT operator enables us to reverse a comparison operation. The AND and OR operators enable us to combine multiple comparison operators into one step. The following code shows how to use the logical operators:

(x > 5 && x < 10) // true if x is greater than 5 and less than 10
(x > 5 || x < 1) // true if x is greater than 5 or less than 1
!(x == y) // returns true if x is not equal to y

Now let's see how we can cast a variable.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required