I am trying to understand a pretty simple, existing sketch, with a view to adding to it, and am struggling to get my head round what I'm pretty sure is debugging / scaffolding.
I've read that "#ifdef allows that a section of a program is compiled only if the defined constant that is specified as the parameter has been defined, independently of its value"
But I'm slightly confused.
At the start of the sketch are the following definitions.
#define DEBUG 0
//#define TEST_LIGHTS
//#define TEST_ADC_SPEED
//#define REPORT_TIMING
Obviously only the first definition has any significance, because the others are commented out.
Then, early in the setup function, there is the following:
#ifdef TEST_LIGHTS
testLights();
#endif
Am I right in understanding that if TEST_LIGHTS is defined, the function testLights gets called. But as #define TEST_LIGHTS is commented out, the function testLights is not called (or even compiled)?
Secondly, in the definitions above, DEBUG is the only one not commented out. So when we get to ...
#ifdef DEBUG
String serData = String("H_n_A : ") + H_n_A + "\n"
+ "L O : " + L_o + "\n";
Serial.println(serData);
#endif
... this should display some text in the serial window.
However DEBUG is defined at the start as having a value of zero, and I can't see any significnce to this, especially as the other definitions do not include a value.
Is there a reason for this?