tripple and ?

I have tried the following

bool var1 = true;
bool var2 = false;
bool var3 = true;


if(var1 ==true && var2 == false && var3 == true){

Serial.println("IF was positive");

Serial prints of the vars put out 1-0-1

So the if should be positive, but its not. The Serial print inside the if gets never out.


Please post a complete program that shows the problem. When and how are the variables declared and initialised, for example ?

Did you type this in?

Look carefully at the source and see if there is a semicolon between the closing parenthesis of the if and the opening brace.

What is going on here? I do not see a setup() function and I do not see a loop() function. Is this really code for an Arduino?

To post code and/or error messages:

  1. Use CTRL-T in the Arduino IDE to autoformat your complete code.
  2. Paste the complete autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
  3. Paste the complete error message between code tags (the </> button)
    so that we can easily see and deal with your messages.
  4. If you already posted without code tags, you may add the code tags by
    editing your post. Do not change your existing posts in any other way.
    You may make additional posts as needed.

Before posting again, you should read the three locked topics at the top of the Programming Questions forum, and any links to which these posts point.

If your project involves wiring, please provide a schematic and/or a wiring diagram and/or a clear photograph of the wiring.

Good Luck!