Bird
0
0

What will happen if you call GPIO.add_event_detect twice on the same pin without removing the first event detect?

medium📝 Predict Output Q5 of 15
Raspberry Pi - LED and Button Projects
What will happen if you call GPIO.add_event_detect twice on the same pin without removing the first event detect?
AAn exception is raised indicating event detect already added.
BBoth callbacks will be called on event.
CThe second event detect silently replaces the first.
DThe program crashes immediately.
Step-by-Step Solution
Solution:
  1. Step 1: Recall GPIO event detect behavior

    Adding event detect twice on the same pin without removing the first causes an error.
  2. Step 2: Understand error handling

    The library raises a RuntimeError indicating event detection is already added on that pin.
  3. Final Answer:

    An exception is raised indicating event detect already added. -> Option A
  4. Quick Check:

    Double add_event_detect = RuntimeError [OK]
Quick Trick: Remove event detect before adding again [OK]
Common Mistakes:
  • Assuming callbacks stack
  • Thinking second replaces first silently
  • Expecting program crash instead of exception

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes