Boolean

The Boolean data type can contain one of two possible values, true or false. The following example shows how to declare a variable to be of the Boolean type:

boolean myBool = true;

The preceding code declares a variable named myBool of the Boolean type and sets an initial value of true. Boolean types are used a lot within a standard Arduino program and all comparison operations, as we will see later in this chapter, return a Boolean value.

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.