Recall & Review
beginner
What is the basic purpose of button press detection in Raspberry Pi projects?
To detect when a physical button connected to the Raspberry Pi is pressed or released, allowing the program to respond to user input.
Click to reveal answer
beginner
Which Raspberry Pi library is commonly used to detect button presses in Python?
The RPi.GPIO library is commonly used to read input from buttons connected to the Raspberry Pi's GPIO pins.
Click to reveal answer
intermediate
Why do we use pull-up or pull-down resistors with buttons on Raspberry Pi GPIO pins?
Pull-up or pull-down resistors ensure the GPIO pin reads a stable HIGH or LOW value when the button is not pressed, preventing random noise or floating values.
Click to reveal answer
intermediate
What does the following Python code do?
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
It sets GPIO pin 18 as an input pin with an internal pull-up resistor enabled, so the pin reads HIGH when the button is not pressed.
Click to reveal answer
intermediate
How can you detect a button press event without constantly checking the button state in a loop?
By using event detection functions like GPIO.add_event_detect() to trigger a callback function when the button state changes.
Click to reveal answer
Which GPIO pin mode should you use to read a button press on Raspberry Pi?
✗ Incorrect
GPIO.IN sets the pin as input to read signals like button presses.
What is the purpose of a pull-up resistor when connecting a button to a GPIO pin?
✗ Incorrect
A pull-up resistor ensures the pin reads HIGH when the button is open (not pressed).
Which Python library is most commonly used for GPIO button detection on Raspberry Pi?
✗ Incorrect
RPi.GPIO is designed for Raspberry Pi GPIO pin control.
What does GPIO.add_event_detect() do?
✗ Incorrect
It sets up event detection to call a function when a button press happens.
If a button is connected with a pull-down resistor, what will the GPIO pin read when the button is not pressed?
✗ Incorrect
Pull-down resistor keeps the pin LOW when the button is not pressed.
Explain how to set up a button on a Raspberry Pi GPIO pin to detect presses using Python.
Think about how to prepare the pin and how to check the button press.
You got /4 concepts.
Describe why pull-up or pull-down resistors are important when detecting button presses on Raspberry Pi.
Consider what happens if the pin is left unconnected.
You got /3 concepts.