Skip to content

Button Input and Pull Resistors

Beginning of the lesson

Button Input and Pull Resistors

In the last lesson you told the Pico what to do by turning an LED on and off. Now we flip the direction: instead of the Pico talking to the world, it will listen to it. A push button is the simplest way for a human to send a signal into a microcontroller, and learning to read it correctly is the doorway to every keypad, sensor, switch and control you will ever build.

The big idea in one sentence

A digital input pin does not measure "is a button pressed?" — it measures voltage. It reports 1 when it sees a voltage near 3.3 V and 0 when it sees a voltage near 0 V. Your whole job when reading a button is to make sure the pin always sees one of those two clear voltages and never gets left "floating" in between.

What you will be able to do

  • Configure a GPIO pin as a digital input with Pin.IN.
  • Read the pin with .value() and understand what 0 and 1 mean.
  • Explain the floating pin problem and why it makes buttons act possessed.
  • Use the Pico's internal pull-up and pull-down resistors and wire a button for each.
  • Toggle an LED on each press and count presses reliably.
  • Understand button bounce and fix it with software debouncing.

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers