internal pullup resistors & digitalWrite

Hi nick,

This was so you don't have to explain things like the switch pulled the digital in LOW, so digitalWrite HIGH to turn the LED on(it was counter-intuitive to a lot of people).

Yes, a lot of things that beginners need to know can be counter intuitive at first, but explaining it as follows is perhaps clearer:

“when the switch is pushed LOW (digitalRead is LOW) the LED is turned on (digitalWrite HIGH)”

As you say, different people have different takes on this, but FWIW, mine is that the following code (without the external resistor) is easer:

 void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input with pull-up resistor enabled:
  pinMode(buttonPin, INPUT_PULLUP);     
}

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

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