- LED_BUILTIN is a defined symbol in pins_arduino.h. It should be used. Don't made a variable for it.
- (as of 1.00 4/10/12 it is incorrectly defined if using ETHERNET board, it should be 9 )
- There is a big difference between using #define and int
- #define
acts as an alias and is a preprocessor directive. The substitution occurs when the source is compiled. It allocates no storage. The hardware instruction set contain a class of short "immediate" instructions which do not require fetching an operand for small values, like 13. Using define permits the compiler to use them
- int
- allocates 2 bytes in precious RAM (even byte takes one).
- In addition the generated code cannot use an immediate instruction.
- The value for LED_BUILTIN is not actually the number of a hardware pin, rather is is a software definition used by the library functions
- Unfortunately digitalWrite as defined in wiring_digital.c as seen in some examples is hugely more complicated then simply setting a value on a pin. The code generated for the call is longer with the int
- with define:
- 8d e0 ldi r24, 0x0D ; 13
- 61 e0 ldi r22, 0x01 ; 1
- 0e 94 41 01 call 0x282 ; 0x282
- with int
- 80 91 00 01 lds r24, 0x0100 ; LED13
- 61 e0 ldi r22, 0x01 ; 1
- 0e 94 61 01 call 0x2c2 ; 0x2c2
The hardware instruction set for the ATmel AVR micro contoller (as well an many other micro computer systems ) includes other immediate instructions. These include instructions for setting, resetting and testing flags. They handle I/O ports extremely efficiently. There also exist immediate instructions to add, subtract(with and without carry), and, or and compare as well as skip instruction which test I/O ports directly. They require referencing the specific port and pin.
Refer to ATmel AVR instruction set document 0856I–AVR–07/10 at
http://www.atmel.com/Images/doc0856.pdfFor example
CBI Clears a bit in an I/O register which is specified in the instruction takes only 2 bytes (see page 48)
++++++++++++++++++++++++++
Can the reference pages
http://arduino.cc/en/Reference/Int and
http://arduino.cc/en/Reference/UnsignedInt and
http://arduino.cc/en/Reference/DigitalWrite
http://arduino.cc/en/Reference/PinMode
please be revised to replace unsigned int ledPin = 13; with something better.Please.

[/list][/list][/list][/list][/list][/list]