For those new to arduino,
I have been programming professionally since 1978, and could see NO reason to use const instead of define, based on my experience and reading of the documentation.
However, the arduino IDE does NOT differentiate between two defined "variables" with the same root properly
(In my way of thinking, anyway, it can get confused)
#define ABC 123.456 * 789
#define ABC_DEF 654.321
Is replaced with
#define 123.456 * 789_DEF 654.123
That isn't too bad, it does get resolved properly, but
#define ABC XYZ
#define ABCDEF QWERTY
#define XYZDEF ABCDEFG
Gives
Gives a compile error (already defined, because ABC is replaced with XYZ in the second line)
#define ABC XYZ
#define DEF ABCDEFG
means that when you use DEF you'll get XYZDEFG not ABCDEFG
once I knew that, I was far more careful, but still used defines instead of consts
Because the documentation led me to believe that consts take up memory, and it is limited
But the I found an include that defined something that caused the same kind of problem. And it took AGES to figure it out. Everything was working, I added a few new functions, and started getting strange results in functions that had been working before, and nothing had changed.
So, I started looking at consts.
Well, to my surprise,
Using const int i_variable_for_whatever does NOT use memory under ant circumstances that I have encountered so far.
AND it is MUCH MUCH easier to ensure that calculations are type converted properly
const double cd_pi_value = 3.14159 ;
const int ci_max_encoder_clicks = 80 ;
#define PI_VALUE 3.14159
#define MAX_ENCODER_CLICKS
double d_pi_clicks = cd_pi_value * ci_max_encoder_clicks ;
vs
double d_pi_clicks = double(PI_VALUE) * double(MAX_ENCODER_CLICKS) ;
double() is required, or it doesn't calculate correctly
When compiled, the version with consts uses the same variable storage memory, and LESS programming space
(Might not for this example, but it did for me full sketch)
So, after 36 years of programming, I have changed my use of constants and defines (on the arduino at least)