Fading example confusion & other errors.

In the fade example its should be fading an LED from 0 to 255 or basically from off to full on. The from full on to off. But when the code is executed on the Duemilenova its reversed. The LED starts full on then fades off and back on again. The fade happens just fine. But it seams that 0 is on and 255 if off. Am i missing something here? Ive verified this by removing:

// fade out from max to min in increments of 5 points:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);         
    // wait for 30 milliseconds to see the dimming effect    
    delay(30);                            
  }

from the loop so the LED only fades up but it starts full on then fades off.

Also there is a documentation error in the Button example. When describing the purpose of the program is states, "Turns on and off a light emitting diode(LED) connected to digital pin 13, when pressing a pushbutton attached to pin 7.". Yet the program designates pin 2 for the button and the documentation ofter that says that the pushbutton will be attached to pin 2.

But it seams that 0 is on and 255 if off

It depends on which way your LED is connected - if it is between the output pin and the supply rail, then yes, the LED will be off when the PWM value is 255, and on when the PWM value is 0. Here, the output pin is sinking current.

If your LED is connected between output pin and ground (this is more usual), then the LED is off for a PWM value of 0, and on for a value of 255. The output pin is sourcing current.

Perhaps the connection scheme could be made clearer in the example. [edit]Nope, the diagram clearly shows the LED connecting to ground - did you check your wiring? http://arduino.cc/en/Tutorial/Fading[/edit]

The Button example sounds like a typo. [edit]You mean this one: http://arduino.cc/en/Tutorial/Button? No mention of pin 7[/edit]

The example sketch that comes with Arduino 0017 for Windows mentions pin 7 at the top but uses pin 2 through the rest of the sketch.

/*
  Button
 
 Turns on and off a light emitting diode(LED) connected to digital  
 pin 13, when pressing a pushbutton attached to [glow]pin 7[/glow]. 
 
 
 The circuit:
 * LED attached from pin 13 to ground 
 * pushbutton attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground
 
 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.
 
 
 created 2005
 by DojoDave <http://www.0j0.org>
 modified 17 Jun 2009
 by Tom Igoe
 
  http://www.arduino.cc/en/Tutorial/Button
 */

// constants won't change. They're used here to 
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    // turn LED on:    
    digitalWrite(ledPin, HIGH);  
  } 
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
  }
}