Bird
0
0

Why is it important to call GPIO.setmode() before setting up pins in RPi.GPIO?

hard📝 Conceptual Q10 of 15
Raspberry Pi - GPIO Basics with Python
Why is it important to call GPIO.setmode() before setting up pins in RPi.GPIO?
ABecause it initializes the GPIO pins to output mode by default
BBecause it defines the pin numbering system to avoid confusion
CBecause it disables warnings from previous runs
DBecause it automatically calls GPIO.cleanup()
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of GPIO.setmode()

    This function sets the numbering system (BOARD or BCM) so the program knows how to interpret pin numbers.
  2. Step 2: Evaluate other options

    It does not initialize pins to output, disable warnings, or call cleanup automatically.
  3. Final Answer:

    Because it defines the pin numbering system to avoid confusion -> Option B
  4. Quick Check:

    setmode defines numbering system = B [OK]
Quick Trick: Always set pin numbering mode first with GPIO.setmode() [OK]
Common Mistakes:
  • Thinking setmode sets pin direction
  • Assuming it disables warnings
  • Expecting automatic cleanup call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes