code changes

I have the arduino uno. The first example I copied from the book, and had no issue. The second used const int for the LED and button, in the book really getting started with arduino #define is used. Does anyone know why, if so where can I accurate codes for my uno.

thanks

Can use either, all they do is keep the code from changing the value stored for that name.

I get by with just byte pinX = 2; // or 3,4,5, etc all the time.

I personally think the code is pretty sloppy if you're worried about the code changing your pin assignments on you for example. The other advantage of using #define or const is the asssignment aren't treated as variables, so it saves a few bytes of the 2K of SRAM space. My biggest program to date is about 25 printed pages long, all variables were byte, int, or unsigned long, 2K of SRAM was not an issue. If you have long things, like messages to be displayed on a screen, and you don't use PROGMEM to ensure they are stored in Flash memory, then you might start seeing problems. Or if you have very large arrays that will be changing, that also uses a lot of SRAM.

define myValue 200 and const int myValue = 13; do not take up any SRAM (like CrossRoads says we have 2K of SRAM in the UNO).

However: int myValue = 200; takes up two SRAM locations (since it is an integer) out of the 2K available.