PyRaspBeta

← All practice problems

Raspberry Pi practice problem · Buttons & input

Bring your own pull-up

EasyBudget $3Python · gpiozero

The Pi's internal pull-ups are weak (about 50 kΩ). On long wires people fit a stronger one on the board.

Build: a push button from GPIO27 to ground, and a 10 kΩ resistor from GPIO27 to 3.3 V (the pull-up).

Program: print Pressed once when the button goes down and Released once when it comes up. Since the resistor does the pulling, you can switch the internal pull off: Button(27, pull_up=None, active_state=False). Ignore contact bounce.

The test presses at 1.0 s and 2.5 s, 0.5 s each.

More in Buttons & input