[NEWB] does int occupy two bytes in flash

Hello Arduino People, I am new to Arduino but am impressed so far with the board and IDE. Kudos to the developers. Especially the consideration to Macintosh users such as myself. My first question is this - I note in many example programs the following kind of thing:-

int ledPin = 13; // LED connected to digital pin 13

... now ledPin is as far as I can see able to be a BYTE (0-255) rather than an INT (0-65535). Does the compiler deal with this kind of thing transparently to the programmer? Or would it be better practice to define as byte where possible?

... or is there a FAQ where such dumb questions are answered? Regards, Tony Barry

The compiler does what you tell it, which is to use 2 bytes of RAM to store this number. In addition, some flash is occupied with the initialization code. The compiler assumes you know what you're doing and does what you tell it.

A better use of resources would be to

define LEDPIN 13

This uses no RAM by defining a constant. Of course, it assumes you don't change the value during program execution, but how many times do you change which pin something is attached to during program execution?

-j

Thanks kg, I appreciate your rapid response.

Regards, Tony Barry