This code works but only with these two lines outside of the #ifdef
#include <Ethernet.h> //I do not know why this cannot be encapsulated by the ETH #ifdef/#endif
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //I do not know why this cannot be encapsulated by the ETH #ifdef/#endif
Can someone tell me why this is? Also if there are any other thoughts on my code I would love to hear them. I have an electronics and radio background and I haven't coded much.
I have the complete code in an attachment as wit exceeded the 9000 char limit
Put the statements back in the #ifdef block. Enable verbose mode while compiling (File + Preferences). Look at the cpp file that is created from your ino file. I'm pretty sure that you'll see why having them in the #ifdef block doesn't work (for some definition of work, since you didn't say what happens when the statements are in the #ifdef block).
My apologies, I just realized that. It behaves as if I have a syntax error.
I have put the lines back in and commented the #define for each of the ethernet bits, I get this on compile.
I will try this verbose mode
Compiling 'time_modular' for 'Arduino Mega w/ ATmega2560 (Mega 2560)'
time_modular.ino:In function 'void setup()'
time_modular.ino:69:3: error: 'Serial' was not declared in this scope
time_modular.ino:72:15: error: 'OUTPUT' was not declared in this scope
time_modular.ino:72:21: error: 'pinMode' was not declared in this scope
time_modular.ino:123:20: error: 'requestSync' was not declared in this scope
time_modular.ino:In function 'void loop()'
time_modular.ino:132:7: error: 'Serial' was not declared in this scope
time_modular.ino:133:23: error: 'processSyncMessage' was not declared in this scope
time_modular.ino:137:24: error: 'digitalClockDisplay' was not declared in this scope
time_modular.ino:140:21: error: 'HIGH' was not declared in this scope
time_modular.ino:140:25: error: 'digitalWrite' was not declared in this scope
time_modular.ino:142:21: error: 'LOW' was not declared in this scope
time_modular.ino:142:24: error: 'digitalWrite' was not declared in this scope
time_modular.ino:144:13: error: 'delay' was not declared in this scope
time_modular.ino:In function 'void digitalClockDisplay()'
time_modular.ino:149:3: error: 'Serial' was not declared in this scope
time_modular.ino:150:23: error: 'printDigits' was not declared in this scope
time_modular.ino:In function 'void printDigits(int)'
time_modular.ino:163:3: error: 'Serial' was not declared in this scope
time_modular.ino:In function 'void processSyncMessage()'
time_modular.ino:184:6: error: 'Serial' was not declared in this scope
time_modular.ino:In function 'time_t requestSync()'
time_modular.ino:206:2: error: 'Serial' was not declared in this scope
Error compiling
The IDE adds code (#include statements and function prototypes) to your sketch. WHERE it puts them is critical.
If you put the conditional stuff in another file, and include, or not, that file, the Arduino IDE will put it's stuff in the ino file in the correct place.
Having executable statements in the first #ifdef block in the ino file is what is causing problems. Moving that code to another file, that the preprocessor deals with (rather than the IDE) will solve the problem.