Reputation: 21
I tried to add an boolean array that will store current status of user. This is my array:
bool enterStatus[5];
Later in the code, i will check the array based on the id i get and then if the id is false, set it true and vice versa.
Assume the id is 1,
if(enterStatus[id] == true){
enterStatus[id] = false;
} if(enterStatus[id] == false){
enterStatus[id] = true;
}
Serial.print(enterStatus[id]);
That's what i try. The output i get:
11111111111111111111111111111111
I want the the loop output to be:
1010101010101010101010101
Where did i do wrong? please correct me. Thanks in advance.
Upvotes: 1
Views: 62
Reputation: 66
your if
's are wrong as your check if true
and set to false
, then if false
(which it's now gaurenteed to be), will be set to true
. please put an else
before the second if
Upvotes: 2