Tutorial/Button schematics


The "Circuit" and the "Schematic" on the tutorial page "Button" show the same wiring correct? Well, apart from using two different GND connection points. And what they show is how to use a pull-down resistor, correct?
The placement of the schematic made me think it would show the wiring for a pull-up resistor.

(I understand where a pull-up resistor would be placed).


Most of us use the internal pullup resistor, with an external switch that connects the button to Gnd when pressed:

// pre setup
byte pinX = 2; // 2 to 19 generally
// or
const byte pinX = 2; // 2 to 19 generally

// in setup
pinMode (pinX, INPUT_PULLUP);

// in loop
if (digitalRead(pinX) == LOW){
// switch was pressed, do something
// optional - do something else