Yes. (but)
Const [variable] is preferred over #define [variable] because const tells the compiler that the variable will not change and it gets put in memory set aside by the compiler as "read only". Very helpful if your program is running low on RAM for variables.
#define is simply a precompiler instruction to replace stuff. So
#define abc "This is a long string that I don't want to type over and over"
means that the precompiler replaces all occurrences of "abc" with "This is a long string that I don't want to type over and over". Taking 65 bytes of RAM. Fortunately the Arduino compiler is smart enough to only make one copy of the string in RAM.
Now, the but... #define is a precompiler instruction const is a compile instruction and must be terminated with a semicolon.
Not every #define can become a const.
// DEBUG_SERIAL statements will only print if DEBUG is nonzero
#define DEBUG 0
#define DEBUG_SERIAL if(DEBUG) Serial
because that if() is also not a pre-processor statement.
And might even be easier to make a DebugPrint class and a NoDebugClass which have the same interface as Print and of which the last simply does nothing (project idea....)
SteveMann:
Yes. (but)
Const [variable] is preferred over #define [variable] because const tells the compiler that the variable will not change and it gets put in memory set aside by the compiler as "read only". Very helpful if your program is running low on RAM for variables.
The compiler is clever enough to optimize away const variables. They basically get hard-coded into the program, just like the rest of your code. This makes
const int variable=13;
Serial.println(variable);
take up the same amount of space as (RAM and PROGMEM)