IF Statement Multiple Conditions - Arduino Forum

IF Statement multiple conditions Projects Programming November 12, 2018, 1:53am 1

if i want all 3 conditions to be met at 1 time which is the correct format.

if ((sensreading > Params.LowAlert) && (Params.Control) && SkipDelay != 0 ) {

the compiler gives warning about this second one if ((sensreading > Params.LowAlert) && (Params.Control) && (SkipDelay != 0 )) {

the braces and brackets for multiple conditions is still confusing to me

November 12, 2018, 2:30am 2

The first one is the correct format and the second one (as the compiler told you) is not.

The parentheses around Params.Control are harmless but unnecessary.

The parentheses around sensreading > Params.LowAlert may be unnecessary but make the expression more clear.

November 12, 2018, 2:34am 3

{} - braces [] - brackets () - parentheses

Unlike braces and brackets, parentheses cost nothing and serve to clarify order of execution. It seldom hurts to have too many (as long as they're matched) and also aid in (humans) understanding what's going on. With your example, the tests > and != have higher precedence than && so you could actually get away with if (sensreading > Params.LowAlert && Params.Control && SkipDelay != 0 ){ but for clarity, and again at no cost, it is better style to go with if ((sensreading > Params.LowAlert) && (Params.Control) && (SkipDelay != 0 )) { and we all know style matters, others may not be immediately aware of the operator precedence.

FYI Precedence.JPG Precedence.JPG505×653 50.6 KB

Precedence.JPG Precedence.JPG505×653 50.6 KB

November 12, 2018, 2:45am 4

the compiler gives warning about this second one if ((sensreading > Params.LowAlert) && (Params.Control) && (SkipDelay != 0 )) {

Proof? Show me the warning.

November 12, 2018, 2:57am 5

DKWatson: the compiler gives warning about this second one if ((sensreading > Params.LowAlert) && (Params.Control) && (SkipDelay != 0 )) {

Proof? Show me the warning.

its a strange error. the codes is over 3200 lines now

Arduino: 1.8.6 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)" ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1115:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - FloatSwitchResetMillis >= FloatSwitchResetDelay) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1121:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if ((millis() >= orpMinMaxWait) && (!OrpBoot)) { //wait to update orpminmax ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1151:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - tempdelaycomp >= tempdelay) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1155:43: warning: right operand of comma operator has no effect [-Wunused-value] ph1reading = pHvalue1 * 14.0 / 1024, 1; ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1176:43: warning: right operand of comma operator has no effect [-Wunused-value] ph2reading = pHvalue2 * 14.0 / 1024, 1; ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1277:22: warning: unused variable 't' [-Wunused-variable] for (auto& t : timer) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1286:22: warning: unused variable 't' [-Wunused-variable] for (auto& t : timer) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1296:22: warning: unused variable 't' [-Wunused-variable] for (auto& t : timer) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1383:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - LcdDelay > LcdPause && SkipStartupDelay == 2) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1430:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - startcounter > startcountdelay) { //refresh lcd screen ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1568:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - startcounter > startcountdelay) { //refresh lcd screen ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1607:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - startcounter > startcountdelay) { //refresh lcd screen ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1637:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - AutoControlwait >= AutoControlAlertDelay) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1647:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - startcounter > startcountdelay) { //refresh lcd screen ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1677:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - calibratescreenwait >= calibratescreendelay) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1681:50: warning: right operand of comma operator has no effect [-Wunused-value] calibratevalue1 = pHvalue1 * 14.0 / 1024, 1; ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1688:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - calibratescreenwait >= calibratescreendelay) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1692:50: warning: right operand of comma operator has no effect [-Wunused-value] calibratevalue1 = pHvalue2 * 14.0 / 1024, 1; ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1763:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - PhWarnWait >= Ph1WarnDelay) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1771:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - WaterWarnWait >= WaterWarnDelay) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1779:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - watertempwait >= watertempdelay) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1819:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - minmaxwait >= MinMaxUpdateDelay) { ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:1943:46: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (millis() - DayNightStateChangeMillis >= PhotoSensor_Delay) { virtual void enableAutoRange(bool enabled) {}; ^ C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino: In function 'saveParam': C:\Users\User\Desktop\my programs\main_sketch_3\main_sketch_3.ino:389:1: internal compiler error: Segmentation fault } ^ Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. lto-wrapper.exe: fatal error: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc returned 1 exit status compilation terminated. c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed collect2.exe: error: ld returned 1 exit status C:\Users\User\Documents\Arduino\libraries\Adafruit_Sensor exit status 1 Error compiling for board Arduino/Genuino Mega or Mega 2560. November 12, 2018, 3:08am 6

vaj4088: The first one is the correct format and the second one (as the compiler told you) is not.

The parentheses around Params.Control are harmless but unnecessary.

The parentheses around sensreading > Params.LowAlert may be unnecessary but make the expression more clear.

Nonsense. I've run all combinations through the IDE and the command line and can't generate a warning.

If any option were to be deemed 'correct' it would be

if ((sensreading > Params.LowAlert) && Params.Control && (SkipDelay != 0 ))

November 12, 2018, 3:10am 7

okay im still having a problem. i've marked in the code //start here and //end here between those two markers is the part of the code im woring on. in that part of code i marked remove these and it will compile. i had to modify the iremote library timer pins..

libraries.zip (229 KB)

November 12, 2018, 3:11am 8

Unless there are problems with my editor (and there aren't) I find nothing in your error dump relating to that statement.

November 12, 2018, 3:16am 9

If there are problems elsewhere in your code, that's another issue. If you cannot reproduce the warning you claim to have had in your original post, I'd say pass it off as a side effect of a different problem. There is no reason that the statement(s) would generate any warnings. And I have proof!

November 12, 2018, 3:16am 10

DKWatson: Unless there are problems with my editor (and there aren't) I find nothing in your error dump relating to that statement.

and you compiled the sketch i uploaded?

November 12, 2018, 3:23am 11

Proof;

CODE #define prt(x)  Serial.println(x) void setup() {    Serial.begin(38400);    struct    {        byte    LowAlert;        byte    Control;    }Params;        Params.LowAlert = 0;    Params.Control = 1;    byte sensreading = 1;    byte SkipDelay = 1;        if (sensreading > Params.LowAlert && Params.Control && SkipDelay != 0) prt(11);    else prt(22);    if ((sensreading > Params.LowAlert) && Params.Control && SkipDelay != 0) prt(33);    else prt(22);    if ((sensreading > Params.LowAlert) && (Params.Control) && SkipDelay != 0) prt(55);    else prt(22);    if ((sensreading > Params.LowAlert) && (Params.Control) && (SkipDelay != 0)) prt(77);    else prt(22);    if (sensreading > Params.LowAlert && (Params.Control) && (SkipDelay != 0)) prt(99);    else prt(22);    if (sensreading > Params.LowAlert && Params.Control && (SkipDelay != 0)) prt(111);    else prt(22);    if (sensreading > Params.LowAlert && (Params.Control) && SkipDelay != 0) prt(333);    else prt(22); } void loop() { } COMPILER MESSAGES D:\Arduino_legacy\1.8.5\arduino-builder -dump-prefs -logger=machine -hardware D:\Arduino_legacy\1.8.5\hardware -hardware D:\Arduino_legacy\1.8.5\portable\packages -tools D:\Arduino_legacy\1.8.5\tools-builder -tools D:\Arduino_legacy\1.8.5\hardware\tools\avr -tools D:\Arduino_legacy\1.8.5\portable\packages -built-in-libraries D:\Arduino_legacy\1.8.5\libraries -libraries D:\Arduino_legacy\1.8.5\portable\sketchbook\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path C:\Users\Watson\AppData\Local\Temp\arduino_build_384792 -warnings=all -build-cache C:\Users\Watson\AppData\Local\Temp\arduino_cache_684440 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -verbose D:\Arduino_legacy\1.8.5\portable\sketchbook\forum\forum.ino D:\Arduino_legacy\1.8.5\arduino-builder -compile -logger=machine -hardware D:\Arduino_legacy\1.8.5\hardware -hardware D:\Arduino_legacy\1.8.5\portable\packages -tools D:\Arduino_legacy\1.8.5\tools-builder -tools D:\Arduino_legacy\1.8.5\hardware\tools\avr -tools D:\Arduino_legacy\1.8.5\portable\packages -built-in-libraries D:\Arduino_legacy\1.8.5\libraries -libraries D:\Arduino_legacy\1.8.5\portable\sketchbook\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path C:\Users\Watson\AppData\Local\Temp\arduino_build_384792 -warnings=all -build-cache C:\Users\Watson\AppData\Local\Temp\arduino_cache_684440 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -verbose D:\Arduino_legacy\1.8.5\portable\sketchbook\forum\forum.ino Using board 'uno' from platform in folder: D:\Arduino_legacy\1.8.5\hardware\arduino\avr Using core 'arduino' from platform in folder: D:\Arduino_legacy\1.8.5\hardware\arduino\avr WARNING: Category '' in library ArduinoUnit is not valid. Setting to 'Uncategorized' Detecting libraries used... "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\cores\arduino" "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\variants\standard" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\sketch\forum.ino.cpp" -o "nul" Generating function prototypes... "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\cores\arduino" "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\variants\standard" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\sketch\forum.ino.cpp" -o "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\preproc\ctags_target_for_gcc_minus_e.cpp" "D:\Arduino_legacy\1.8.5\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\preproc\ctags_target_for_gcc_minus_e.cpp" Compiling sketch... "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\cores\arduino" "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\variants\standard" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\sketch\forum.ino.cpp" -o "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\sketch\forum.ino.cpp.o" Compiling libraries... Compiling core... Using precompiled core Linking everything together... "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p  -o "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/forum.ino.elf" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\sketch\forum.ino.cpp.o" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/..\arduino_cache_684440\core\core_arduino_avr_uno_a7d0666b8a01d077cdadb0d13259d8a6.a" "-LC:\Users\Watson\AppData\Local\Temp\arduino_build_384792" -lm "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0  "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/forum.ino.elf" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/forum.ino.eep" "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-objcopy" -O ihex -R .eeprom  "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/forum.ino.elf" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/forum.ino.hex" Sketch uses 1842 bytes (5%) of program storage space. Maximum is 32256 bytes. Global variables use 188 bytes (9%) of dynamic memory, leaving 1860 bytes for local variables. Maximum is 2048 bytes. OUTPUT 11 33 55 77 99 111 333 November 12, 2018, 3:23am 12

im not sure what the root of the problem is but removing the 2 if statements in the code i uploaded allows it to compile. even if i move them it will compile

November 12, 2018, 3:25am 13

No, I tested the statements in your original post. This was not about fixing your sketch.

November 12, 2018, 3:25am 14

DKWatson: Proof;

CODE

#define prt(x) Serial.println(x)

void setup() { Serial.begin(38400); struct { byte LowAlert; byte Control; }Params; Params.LowAlert = 0; Params.Control = 1; byte sensreading = 1; byte SkipDelay = 1; if (sensreading > Params.LowAlert && Params.Control && SkipDelay != 0) prt(11); else prt(22); if ((sensreading > Params.LowAlert) && Params.Control && SkipDelay != 0) prt(33); else prt(22); if ((sensreading > Params.LowAlert) && (Params.Control) && SkipDelay != 0) prt(55); else prt(22); if ((sensreading > Params.LowAlert) && (Params.Control) && (SkipDelay != 0)) prt(77); else prt(22); if (sensreading > Params.LowAlert && (Params.Control) && (SkipDelay != 0)) prt(99); else prt(22); if (sensreading > Params.LowAlert && Params.Control && (SkipDelay != 0)) prt(111); else prt(22); if (sensreading > Params.LowAlert && (Params.Control) && SkipDelay != 0) prt(333); else prt(22); }

void loop() { }

COMPILER MESSAGES

D:\Arduino_legacy\1.8.5\arduino-builder -dump-prefs -logger=machine -hardware D:\Arduino_legacy\1.8.5\hardware -hardware D:\Arduino_legacy\1.8.5\portable\packages -tools D:\Arduino_legacy\1.8.5\tools-builder -tools D:\Arduino_legacy\1.8.5\hardware\tools\avr -tools D:\Arduino_legacy\1.8.5\portable\packages -built-in-libraries D:\Arduino_legacy\1.8.5\libraries -libraries D:\Arduino_legacy\1.8.5\portable\sketchbook\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path C:\Users\Watson\AppData\Local\Temp\arduino_build_384792 -warnings=all -build-cache C:\Users\Watson\AppData\Local\Temp\arduino_cache_684440 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -verbose D:\Arduino_legacy\1.8.5\portable\sketchbook\forum\forum.ino D:\Arduino_legacy\1.8.5\arduino-builder -compile -logger=machine -hardware D:\Arduino_legacy\1.8.5\hardware -hardware D:\Arduino_legacy\1.8.5\portable\packages -tools D:\Arduino_legacy\1.8.5\tools-builder -tools D:\Arduino_legacy\1.8.5\hardware\tools\avr -tools D:\Arduino_legacy\1.8.5\portable\packages -built-in-libraries D:\Arduino_legacy\1.8.5\libraries -libraries D:\Arduino_legacy\1.8.5\portable\sketchbook\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path C:\Users\Watson\AppData\Local\Temp\arduino_build_384792 -warnings=all -build-cache C:\Users\Watson\AppData\Local\Temp\arduino_cache_684440 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=D:\Arduino_legacy\1.8.5\hardware\tools\avr -verbose D:\Arduino_legacy\1.8.5\portable\sketchbook\forum\forum.ino Using board 'uno' from platform in folder: D:\Arduino_legacy\1.8.5\hardware\arduino\avr Using core 'arduino' from platform in folder: D:\Arduino_legacy\1.8.5\hardware\arduino\avr WARNING: Category '' in library ArduinoUnit is not valid. Setting to 'Uncategorized' Detecting libraries used... "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\cores\arduino" "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\variants\standard" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\sketch\forum.ino.cpp" -o "nul" Generating function prototypes... "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\cores\arduino" "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\variants\standard" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\sketch\forum.ino.cpp" -o "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\preproc\ctags_target_for_gcc_minus_e.cpp" "D:\Arduino_legacy\1.8.5\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\preproc\ctags_target_for_gcc_minus_e.cpp" Compiling sketch... "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-g++" -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\cores\arduino" "-ID:\Arduino_legacy\1.8.5\hardware\arduino\avr\variants\standard" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\sketch\forum.ino.cpp" -o "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\sketch\forum.ino.cpp.o" Compiling libraries... Compiling core... Using precompiled core Linking everything together... "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-gcc" -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/forum.ino.elf" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792\sketch\forum.ino.cpp.o" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/..\arduino_cache_684440\core\core_arduino_avr_uno_a7d0666b8a01d077cdadb0d13259d8a6.a" "-LC:\Users\Watson\AppData\Local\Temp\arduino_build_384792" -lm "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/forum.ino.elf" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/forum.ino.eep" "D:\Arduino_legacy\1.8.5\hardware\tools\avr/bin/avr-objcopy" -O ihex -R .eeprom "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/forum.ino.elf" "C:\Users\Watson\AppData\Local\Temp\arduino_build_384792/forum.ino.hex" Sketch uses 1842 bytes (5%) of program storage space. Maximum is 32256 bytes. Global variables use 188 bytes (9%) of dynamic memory, leaving 1860 bytes for local variables. Maximum is 2048 bytes.

OUTPUT

11 33 55 77 99 111 333

thankyou dkwatson i understand the parentheses a lot better. still unclear of the precedence level, but the problems persists why?

November 12, 2018, 3:30am 15

anyone that can actually tell me anything about the problem im having

November 12, 2018, 3:34am 16

dkwatson maybe you should upgrade your arduino ide

November 12, 2018, 3:40am 17

and as a matter of fact i dont get the error on ide 1.8.5

November 12, 2018, 3:50am 18

I've just tried compiling the code you attached and come up with only one error, so something is not in sync here.

Arduino: 1.8.6 (Windows 7), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)" Linking everything together... "C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections,--relax -mmcu=atmega2560 -o "C:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833/forum.ino.elf" "C:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833\\sketch\\forum.ino.cpp.o" "C:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833\\libraries\\DHT_sensor_library\\DHT.cpp.o" "C:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833\\libraries\\DHT_sensor_library\\DHT_U.cpp.o" "C:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833\\libraries\\OneWire\\OneWire.cpp.o" "C:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833\\libraries\\LiquidCrystal_I2C\\LiquidCrystal_I2C.cpp.o" "C:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833\\libraries\\Wire\\Wire.cpp.o" "C:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833\\libraries\\Wire\\utility\\twi.c.o" "C:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833\\libraries\\IRremote\\IRremote.cpp.o" "C:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833/..\\arduino_cache_282121\\core\\core_arduino_avr_mega_cpu_atmega2560_0c812875ac70eb4a9b385d8fb077f54c.a" "-LC:\\Users\\Watson\\AppData\\Local\\Temp\\arduino_build_936833" -lm Tone.cpp.o (symbol from plugin): In function `timer0_pin_port': (.text+0x0): multiple definition of `__vector_13' C:\Users\Watson\AppData\Local\Temp\arduino_build_936833\libraries\IRremote\IRremote.cpp.o (symbol from plugin):(.text+0x0): first defined here c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions collect2.exe: error: ld returned 1 exit status Using library DHT_sensor_library at version 1.3.0 in folder: C:\Users\Watson\Documents\Arduino\libraries\DHT_sensor_library Using library OneWire at version 2.3.2 in folder: C:\Users\Watson\Documents\Arduino\libraries\OneWire Using library EEPROM at version 2.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\EEPROM Using library LiquidCrystal_I2C at version 1.1.2 in folder: C:\Users\Watson\Documents\Arduino\libraries\LiquidCrystal_I2C Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire Using library IRremote in folder: C:\Users\Watson\Documents\Arduino\libraries\IRremote (legacy) Using library Adafruit_Sensor at version 1.0.2 in folder: C:\Users\Watson\Documents\Arduino\libraries\Adafruit_Sensor exit status 1 Error compiling for board Arduino/Genuino Mega or Mega 2560. November 12, 2018, 3:50am 19

Excuse me!?

November 12, 2018, 3:52am 20

You're on your own now kid.

next page →
Topic Replies Views Activity
Is there a short cut to this manner of if statement Programming 36 592 May 1, 2024
Non sono sicuro della sintassi IF Software 8 140 August 13, 2025
Suggest parentheses around comparison in operand of '|' [-Werror=parentheses] Programming 50 951 April 14, 2024
Compiling Help please General Guidance 15 121 November 15, 2025
ERROR: Expected '}' before 'else' Programming 44 484 October 17, 2024
Unfortunately, your browser is unsupported. Please switch to a supported browser to view rich content, log in and reply.

Tag » Arduino If Statement 2 Conditions