Bird
0
0

You want to control an LED connected to pin 12 using BCM numbering. Which sequence of commands correctly sets up the pin and turns the LED on, then cleans up properly?

hard📝 Application Q15 of 15
Raspberry Pi - GPIO Basics with Python
You want to control an LED connected to pin 12 using BCM numbering. Which sequence of commands correctly sets up the pin and turns the LED on, then cleans up properly?
AGPIO.setmode(GPIO.BCM)\nGPIO.setup(18, GPIO.OUT)\nGPIO.output(18, True)\nGPIO.cleanup()
BGPIO.setmode(GPIO.BOARD)\nGPIO.setup(12, GPIO.OUT)\nGPIO.output(12, True)\nGPIO.cleanup()
CGPIO.setmode(GPIO.BCM)\nGPIO.setup(12, GPIO.OUT)\nGPIO.output(12, True)\nGPIO.cleanup()
DGPIO.setmode(GPIO.BOARD)\nGPIO.setup(18, GPIO.OUT)\nGPIO.output(18, True)\nGPIO.cleanup()
Step-by-Step Solution
Solution:
  1. Step 1: Match numbering mode with pin number

    Pin 12 in BCM mode corresponds to GPIO12, so setmode(GPIO.BCM) and setup(12) is correct.
  2. Step 2: Confirm output setup and cleanup

    Pin is set as output, turned on with True, and cleanup is called last to reset pins.
  3. Final Answer:

    GPIO.setmode(GPIO.BCM)\nGPIO.setup(12, GPIO.OUT)\nGPIO.output(12, True)\nGPIO.cleanup() -> Option C
  4. Quick Check:

    BCM mode + pin 12 + output + cleanup = GPIO.setmode(GPIO.BCM)\nGPIO.setup(12, GPIO.OUT)\nGPIO.output(12, True)\nGPIO.cleanup() [OK]
Quick Trick: Match setmode with pin number system [OK]
Common Mistakes:
  • Mixing BOARD and BCM numbering
  • Using wrong pin number for chosen mode
  • Forgetting to call cleanup()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes