Go Down

Topic: Tutorial/Button schematics (Read 269 times) previous topic - next topic

Hi,

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).

Thanks,
PowderMonkey

CrossRoads

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

// 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
}
else{
// optional - do something else
}
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up