Data storage: bytes vs. int

Hi I have a somewhat basic question, but I wanted to know how different data types affects my program.

I modified the basic Arduino 'Blink' sketch, to what I think is rather optimizing it, but I'm not sure my logic behind it is correct.

Here is the code I made:

/*This code will turn pin 13 into an output, and 
 * make an led attached to it blink. 


const byte pin13=13;  // This sets varaible name 'pin13' = pin 13
   1. Data type 'byte' ranges stored values 0-54, consumes on 1 byte, while 'int' consumes 2 
      Data type 'int' rangees stored values -32,768 to 32,767, consumes
         2 bytes.  This is too large to use for pins when memory is limited on a board   
   2. The compiler used by the IDE, avr-gcc, knows that 
        a 'const' variable will be left out of RAM since 
        this variable cannot be changed 
void setup() 
  // initialize digital pin 13 as an output.
  pinMode(pin13, OUTPUT);

void loop() 
  digitalWrite(pin13, HIGH);   
  digitalWrite(pin13, LOW);  

Here are my questions:

  1. Does using 'byte' really save memory? When I changed my code from:
    'const byte pin13 = 13'
    ' const int pin13 = 13',

the compiler still said that I was using 928 bytes of program storage space. I excepted that the with 'int' I'd instead use 929 bytes.

  1. If I use an int = 32000, or int = 23, do both of these value each use 2 bytes of data?
  1. Yes, a byte requires 8 bits of storage. You may not see that savings in the program memory, because changeable data are stored in RAM.
  2. Yes, on Arduino (but not on many other computers) an int is by default 16 bits (2 bytes).

Also, a byte is an unsigned data type, so your code comment is not correct. The range is 0 - 255.

When you use a const byte like that, I think the compiler directly writes the number into the code wherever it might be needed, meaning that the byte isn't "stored" anywhere at all.

Many (most?) compilers operate on even byte boundaries. So, it is likely that the number of bytes available that you are seeing will always be an even number.