If else statement

Hello everyone,

I had made a program with if else statement in arduino ide and print out the result at the serial monitor but the messages that printed in the serial monitor did not meet the requirement that I had set in the program. I apologize for my bad english, can anyone help me out on pointing my mistake in the program?

sketch_nov30a.ino (6.38 KB)



 if (0.67 < CurrentL1 < 0.74)

This is a valid C statement but it doesn’t do what you want.
You have to specify a range like this:

 if ((0.67 < CurrentL1) && (CurrentL1 < 0.74))

You’ll have to fix up every similar if statement.


P.S. Read How to post code properly. It makes it a lot easier to read and test your code if it is in code tags It's also a lot easier if you just cut example output from the Serial Monitor and paste it between code tags instead of posting an image.


if (0.67 < CurrentL1 < 0.74)

You will get a compiler warning for code like this - if you have turned on compiler warnings.

How to turn on compiler warnings:
File / Preferences:
Show verbose output during compilation CHECK
Compiler warnings: ALL