If EXT_PIR_SENSOR is defined, the sketch compiles. But if I remove it, the compiler misses PIR_SENSOR_PIN and PIR_THRESHOLD_RAW from managePirSensor() function. This function should not be called at all! Even if I comment it in the loop, the error is still there. It drives me crazy.
Could someone help me out?
This method used to work in my sketches. It is convenient for me to create "options" in the sketch (for example printing to serial monitor during testing and simply remove the define if printing is not needed).
Could someone tell me where these A0, A1, A2, etc. defines are?
I searched the C:\Program Files (x86)\Arduino\hardware\arduino\avr\ directory but couldn't find it.
Yeah, it's a tradeoff. I just searched for "A0" , took two refinements to narrow in.
If you had been lucky, it would have turned up in dozens of files (only). As it was even so much as a space between the '#' and the 'd' woulda left you with nothing.
Of course it should just be a matter of selecting it in you sketch and using the "Find Declaration" option in the Search sub menu.
There is no harm in opening an INO file in notepad++ to execute that, and then to save and open it in the IDE
Actually the easiest would be a 'use external editor' preference.
The defined number is a 'literal' that means that it will just be copied into the code instead of the word.
So it depends what you want to use it for.
in this statement
if (dateTime.Month == MONTH_FOR_SENSOR_LOGGING))
It will be read as
if (dateTime.Month == (11))
I don't see any purpose in casting the '11' from 'int' (16-bit signed on an AVR) to uint8_t
When used in calculation, it can serve a purpose if you want to make sure that the calculation is done in 8-bit if all other variables in the calculation are 8-bit as well.
More important is to make sure that any value that is outside of the 16-bit integer range is specified as such
When concerned about the datatype make it a typed constant...
Yes, I always use constants if it's just a number. But this time I'd like to use it for conditional inclusion at the same time (#15). So my idea was to make things simple, if it is defined compile certain part of the code and use the defined value at the same time.
@Deva_Rishi Thanks for the tips. I think I'll go with the casting, because the dateTime.Month is an uint8_t variable in the struct.