Try Embedded

Full breadboard: power rails and an external pull-up

Use a full-size breadboard's power rails to share 5 V and GND, and read a button through an external pull-up resistor instead of the internal one.

Basic · Beginner

In a real product: Appliance control panel (Consumer electronics): Panel buttons are read through pull-up resistors, often external ones on long wires.

The long strips along the edges of a full breadboard are power rails. They run the whole length of the board, so 5 V and GND can be wired in once and tapped anywhere. This project uses them for an LED's ground and for the pull-up of a button.

What you'll learn

  • Rails: the + and − strips are continuous, unlike the five-hole columns
  • A pull-up resistor: a 10 kΩ from the input to 5 V holds it HIGH until the button pulls it to GND
  • Reading that button with a plain INPUT, since the pull-up is now outside the chip
  • Why a button must never join 5 V and GND directly

How it works

5 V is wired to the top + rail and GND to the top − rail. Pin 2 goes to column 20. A 10 kΩ resistor runs from column 20 to column 24, and a jumper takes column 24 to the + rail: that is the pull-up. The button joins column 20 to column 22, and a jumper takes column 22 to the − rail.

Released, the input is held HIGH through the resistor. Pressed, the button connects it to GND and it reads LOW. The LED on pin 9 lights while the button is held, through its own 220 Ω resistor and the − rail.

Try this

  • Replace INPUT with INPUT_PULLUP, remove the 10 kΩ and see that it still works: the same pull-up, inside the chip.
  • Move the pull-up's jumper to the − rail: the input now floats LOW and the logic inverts.
  • Tap the 5 V rail with a second LED and resistor.

sketch.ino

// A button with an external 10k pull-up on pin 2 lights an LED on pin 9 while pressed (the pin reads LOW then).
const int BUTTON = 2;
const int LED = 9;

void setup() {
  pinMode(BUTTON, INPUT);  // the pull-up is the resistor on the breadboard
  pinMode(LED, OUTPUT);
}

void loop() {
  digitalWrite(LED, digitalRead(BUTTON) == LOW ? HIGH : LOW);
}

Lessons behind it