Bird
0
0

What happens when you use GPIO.add_event_detect on a Raspberry Pi GPIO pin connected to a button?

easy📝 Conceptual Q1 of 15
Raspberry Pi - LED and Button Projects

What happens when you use GPIO.add_event_detect on a Raspberry Pi GPIO pin connected to a button?

AIt disables the pin to save power
BIt continuously reads the pin state in a loop
CIt monitors the pin for specified edge changes and triggers a callback if set
DIt sets the pin as an output to control an LED
Step-by-Step Solution
Solution:
  1. Step 1: Understand GPIO.add_event_detect

    This function sets up an interrupt to detect changes on a GPIO pin.
  2. Step 2: Effect on button input

    When a button is connected, it detects edges (rising/falling) and can call a callback function.
  3. Final Answer:

    It monitors the pin for specified edge changes and triggers a callback if set -> Option C
  4. Quick Check:

    Interrupts detect edges, not continuous reads [OK]
Quick Trick: add_event_detect sets interrupt on pin edges [OK]
Common Mistakes:
  • Thinking it polls the pin continuously
  • Confusing input with output configuration
  • Assuming it disables the pin

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes