Go Down

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

PowderMonkey

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. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Go Up