Bird
0
0

Why is it important to call GPIO.cleanup() at the end of a program using a PIR sensor on Raspberry Pi?

hard📝 Conceptual Q10 of 15
Raspberry Pi - gpiozero Library

Why is it important to call GPIO.cleanup() at the end of a program using a PIR sensor on Raspberry Pi?

ATo increase the sensor detection range
BTo reset GPIO pins and avoid warnings on next run
CTo speed up the sensor response time
DTo permanently disable GPIO pins
Step-by-Step Solution
Solution:
  1. Step 1: Understand GPIO.cleanup purpose

    GPIO.cleanup resets all GPIO pins to default state.
  2. Step 2: Identify why cleanup is needed

    This avoids warnings and conflicts when running programs multiple times.
  3. Final Answer:

    To reset GPIO pins and avoid warnings on next run -> Option B
  4. Quick Check:

    GPIO.cleanup resets pins for clean next use [OK]
Quick Trick: Always call GPIO.cleanup() to reset pins after use [OK]
Common Mistakes:
  • Thinking cleanup affects sensor range or speed
  • Skipping cleanup causing warnings
  • Believing cleanup disables pins permanently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes