i have an INT in my arduino code that i constantly update it's value and i want to check the value and compare it to static values and run IF statments out of it. Something like this
INT = 3
If (int = 1) { run1() }
If (int = 2) { run2() }
If (int = 3) { run3() }
the above example just overwrites the original INT value
In C++ =
is the assignment operator. Please use ==
to compare:
int i = 3;
if (i == 1) { run1(); }
if (i == 2) { run2(); }
if (i == 3) { run3(); }
Also note the lowercase if
and that int
is a keyword which you can't use as variable name.
You might want to check out The Definitive C++ Book Guide and List - it has some useful resources for beginners.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.