You use "int" if you want to store a value between -32768 and 32767 that you want to be able to change. This uses 2 bytes of RAM.
You use "const int" if you want to reference a value by name - you use it just like any ordinary int, but you cannot change the value. This does not use any RAM. The value is used as the actual value wherever it is referenced, just like #define.
You can use #define where you would use "const int", but it lacks the strong type casting of the "const int". It is best to stick to using #define for optional compilation of blocks of code (combined with #if, #ifdef, etc).
If you add cast qualifiers to the value of a #define, then it is just the same as using a "const int". The compiler will produce code that is, if not identical, at least close enough as to be indistinguishable by the average mortal
Thanks a lot for the answers, I have a much more clear panorama now.
And now that we see that one of the advantages is to "save RAM" I have one question, that I think it's related with this.
If I use
const int ThisIsTheLedOnTheRightColorRed = 10;
will that take more bytes than something like
const int LR = 10;
When compiling, it doesn't matter how long my variables are, the program will replace it with a "10" or equivalent, I know it's not exactly 10, but it doesn't matter the variable, right?
I ask, bc I noticed something of this, when trying to make my own digitalWrite function, where I called the function dW() so I thought, now the code instead of having 100 calls to "digitalWrite" will have 100 calls to "dW" so I'm writing less bytes, but I realized it doesn't work that way
Am I crazy right? I'm trying to re-invent the wheel? ]
It should be mentioned, that #define is a preprocessor operator, doing text replacement. #define PI 3.141 will not define a variable, it just replaces every time where PI is found in the source code with 3.141. And there can be the problem, if you write #define PI 3.141o it is fine until the compiler comes and finds out that there is the letter o where it cannot be! Doing so with a variable will show you immideately that there is something wrong. You can get errors even in different files and should be used with utmost care!