The push button is one of the simplest components, yet one of the most widely used in electronics. It allows interaction with a system by sending a signal to a microcontroller or another electronic circuit when the user presses it.

In this text, we will explore the operation of the push button, its different types, and how to use it in practical projects with boards like the Raspberry PICO.

Here is the electronic schematic for the push button on Raspberry PICO:

// Define GPIO 5 pin for the push button
const int buttonPin = 5;
int buttonState = 0; // Variable to store button state

void setup() {
  // Initialize the pin as an input with internal pull-down enabled
  pinMode(buttonPin, INPUT_PULLDOWN);
  // Start serial communication to display the button state
  Serial.begin(9600);
}

void loop() {
  // Read the button state (HIGH if pressed, LOW if not pressed)
  buttonState = digitalRead(buttonPin);

  // Display the button state in the serial monitor
  if (buttonState == HIGH) {
    // The button is pressed (HIGH state)
    Serial.println("Button pressed");
  } else {
    // The button is not pressed (LOW state)
    Serial.println("Button released");
  }

  // Wait for a short time before reading again
  delay(200);
}