The project i am currently working on (automated humidifier) needs to be programmed. i found someone who had already completed this project online and though i would use their example to get started because i really know nothing about programming. the problem is this code has an error in the first line. can anyone help/ tell me what an expected initializer is?
void loop()
int 1 enum Mode {
ModeNormal = 0,
ModeSetting
};
Mode systemMode = ModeNormal;
void updateEncoder9() {
long newPosition = encoder.read();
if (newPosition != target){
if (systemMode == ModeSetting)
target = newPostion;
}
}
void updateData() {
readSensors();
if (correct && humidity <= (target - hysteresis))
correct = false;
else if (!correct && humidity >= (target + hysteresis))
correct = true;
refreshLEDs(correct);
updateRelay(!correct);
}
Arduino: 1.6.10 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\arduino-builder -dump-prefs -logger=machine -hardware "C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware" -tools "C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\tools-builder" -tools "C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\tools\avr" -built-in-libraries "C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\libraries" -libraries "C:\Users\user\Documents\Arduino\libraries" -fqbn=arduino:avr:uno -ide-version=10610 -build-path "C:\Users\user\AppData\Local\Temp\builde85287265e024ad9a0fc44346919d799.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\user\Documents\Arduino\humidifier_example\humidifier_example.ino"
C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\arduino-builder -compile -logger=machine -hardware "C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware" -tools "C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\tools-builder" -tools "C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\tools\avr" -built-in-libraries "C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\libraries" -libraries "C:\Users\user\Documents\Arduino\libraries" -fqbn=arduino:avr:uno -ide-version=10610 -build-path "C:\Users\user\AppData\Local\Temp\builde85287265e024ad9a0fc44346919d799.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\user\Documents\Arduino\humidifier_example\humidifier_example.ino"
Using board 'uno' from platform in folder: C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\arduino\avr
Detecting libraries used...
"C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\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=10610 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\arduino\avr\cores\arduino" "-IC:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\arduino\avr\variants\standard" "C:\Users\user\AppData\Local\Temp\builde85287265e024ad9a0fc44346919d799.tmp\sketch\humidifier_example.ino.cpp" -o "nul"
"C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\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=10610 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\arduino\avr\cores\arduino" "-IC:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\arduino\avr\variants\standard" "C:\Users\user\AppData\Local\Temp\builde85287265e024ad9a0fc44346919d799.tmp\sketch\humidifier_example.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\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=10610 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\arduino\avr\cores\arduino" "-IC:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\arduino\avr\variants\standard" "C:\Users\user\AppData\Local\Temp\builde85287265e024ad9a0fc44346919d799.tmp\sketch\humidifier_example.ino.cpp" -o "C:\Users\user\AppData\Local\Temp\builde85287265e024ad9a0fc44346919d799.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\tools-builder\ctags\5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\user\AppData\Local\Temp\builde85287265e024ad9a0fc44346919d799.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10610 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\arduino\avr\cores\arduino" "-IC:\Users\user\Downloads\arduino-1.6.10-windows\arduino-1.6.10\hardware\arduino\avr\variants\standard" "C:\Users\user\AppData\Local\Temp\builde85287265e024ad9a0fc44346919d799.tmp\sketch\humidifier_example.ino.cpp" -o "C:\Users\user\AppData\Local\Temp\builde85287265e024ad9a0fc44346919d799.tmp\sketch\humidifier_example.ino.cpp.o"
humidifier_example:3: error: expected initializer before 'int'
int 1 enum Mode {
^
humidifier_example:7: error: 'Mode' does not name a type
Mode systemMode = ModeNormal;
^
C:\Users\user\Documents\Arduino\humidifier_example\humidifier_example.ino: In function 'void updateEncoder9()':
humidifier_example:10: error: 'encoder' was not declared in this scope
long newPosition = encoder.read();
^
humidifier_example:11: error: 'target' was not declared in this scope
if (newPosition != target){
^
humidifier_example:12: error: 'systemMode' was not declared in this scope
if (systemMode == ModeSetting)
^
humidifier_example:12: error: 'ModeSetting' was not declared in this scope
if (systemMode == ModeSetting)
^
humidifier_example:13: error: 'newPostion' was not declared in this scope
target = newPostion;
^
C:\Users\user\Documents\Arduino\humidifier_example\humidifier_example.ino: In function 'void updateData()':
humidifier_example:18: error: 'readSensors' was not declared in this scope
readSensors();
^
humidifier_example:20: error: 'correct' was not declared in this scope
if (correct && humidity <= (target - hysteresis))
^
humidifier_example:20: error: 'humidity' was not declared in this scope
if (correct && humidity <= (target - hysteresis))
^
humidifier_example:20: error: 'target' was not declared in this scope
if (correct && humidity <= (target - hysteresis))
^
humidifier_example:20: error: 'hysteresis' was not declared in this scope
if (correct && humidity <= (target - hysteresis))
^
humidifier_example:25: error: 'correct' was not declared in this scope
refreshLEDs(correct);
^
humidifier_example:25: error: 'refreshLEDs' was not declared in this scope
refreshLEDs(correct);
^
humidifier_example:26: error: 'updateRelay' was not declared in this scope
updateRelay(!correct);
^
exit status 1
expected initializer before 'int'