user54800: I want to know if bool variable can be null, or it must have to be true or false:
Base on Arduino description:
A bool holds one of two values, true or false. (Each bool variable occupies one byte of memory.)

user4143: A bool is literally that - a boolean value. So either 1 or 0 - true or false.
In C only pointers can be NULL. Every other primitive type is a value, and NULL is not a value.

user3134: A bool value must be either 0 or 1, or false and true respectively. It is undefined behavior for it to be any other value. When assigning a value to a bool, the compiler will automatically force it to be 0 if it is already 0, or 1 if it is not.
However, as it is a full byte, it is possible to store another value. As mentioned before, however, this is undefined behavior. This means that if it ever happens, or will absolutely happen, the program can do anything: for example, crash the program, output random data, or act like it's truthy, falsy, or both! In fact, that can (again, no guarantees) happen if you store the value 2:
#include <cstdio>

int main() {
    union b_c {
        unsigned char c;
        bool b;
    };
    b_c c;
    c.c = 2;

    if(c.b) puts("true!");
    if(!c.b) puts("false!");
}

(this is designed to run on a computer, but the same thing could happen on an Arduino). Check out what happens when you run it: it outputs both true! and false!! This obviously doesn't make sense, but because we violate the rules by making a bool 2, we loose all guarantees.

So, how is this relevant to your question? There's no valid value a bool can store other than true and false. In C++, null is defined as "an integer literal with value zero". So, if you were to assign null to a bool, it would be stored as false. If you want a separate null value, you're better off using another type that takes up a single byte (e.g. unsigned char or uint8_t, same thing) and storing e.g. 0 for false, 1 for true, and 2 for null.

54800: <p>I want to know if bool variable can be null, or it must have to be true or false:</p>
<p>Base on Arduino description:
A bool holds one of two values, true or false. (Each bool variable occupies one byte of memory.)</p>
 4143: <p>A bool is literally that - a boolean value. So either 1 or 0 - true or false.</p>
<p>In C only pointers can be NULL. Every other primitive type is a value, and NULL is not a value.</p>
 3134: <p>A <code>bool</code> value must be either <code>0</code> or <code>1</code>, or <code>false</code> and <code>true</code> respectively. It is <a href="https://stackoverflow.com/questions/54120862/does-the-c-standard-allow-for-an-uninitialized-bool-to-crash-a-program"><em>undefined behavior</em></a> for it to be any other value. When assigning a value to a <code>bool</code>, the compiler will automatically force it to be 0 if it is already 0, or 1 if it is not.</p>
<p>However, as it is a full byte, it is possible to store another value. As mentioned before, however, this is undefined behavior. This means that if it ever happens, or will absolutely happen, the program can do <em>anything</em>: for example, crash the program, output random data, or act like it's truthy, falsy, or both! In fact, that <em>can</em> (again, no guarantees) happen if you store the value 2:</p>
<pre class="lang-cpp prettyprint-override"><code>#include &lt;cstdio&gt;

int main() {
    union b_c {
        unsigned char c;
        bool b;
    };
    b_c c;
    c.c = 2;

    if(c.b) puts(&quot;true!&quot;);
    if(!c.b) puts(&quot;false!&quot;);
}
</code></pre>
<p>(this is designed to run on a computer, but the same thing could happen on an Arduino). <a href="https://cpp.godbolt.org/z/eM14v7srM" rel="nofollow noreferrer">Check out what happens</a> when you run it: it outputs both <code>true!</code> and <code>false!</code>! This obviously doesn't make sense, but because we violate the rules by making a <code>bool</code> <code>2</code>, we loose all guarantees.</p>
<hr />
<p>So, how is this relevant to your question? There's no valid value a <code>bool</code> can store other than <code>true</code> and <code>false</code>. In C++, <code>null</code> is defined as &quot;an integer literal with value zero&quot;. So, if you were to assign <code>null</code> to a <code>bool</code>, it would be stored as false. If you want a separate null value, you're better off using another type that takes up a single byte (e.g. <code>unsigned char</code> or <code>uint8_t</code>, same thing) and storing e.g. <code>0</code> for <code>false</code>, <code>1</code> for <code>true</code>, and <code>2</code> for null.</p>
