Bird
0
0

Which Python command correctly configures GPIO pin 18 as an output for controlling an LED on Raspberry Pi?

easy📝 Syntax Q3 of 15
Raspberry Pi - LED and Button Projects

Which Python command correctly configures GPIO pin 18 as an output for controlling an LED on Raspberry Pi?

AGPIO.setup(18, GPIO.IN)
BGPIO.setup(18, GPIO.OUT)
CGPIO.output(18, GPIO.OUT)
DGPIO.setmode(GPIO.OUT)
Step-by-Step Solution
Solution:
  1. Step 1: Identify setup function

    GPIO.setup(pin_number, mode) sets pin mode.
  2. Step 2: Set pin 18 as output

    Use GPIO.OUT to configure as output.
  3. Final Answer:

    GPIO.setup(18, GPIO.OUT) -> Option B
  4. Quick Check:

    setup() with GPIO.OUT sets output pin [OK]
Quick Trick: Use GPIO.setup(pin, GPIO.OUT) for output pins [OK]
Common Mistakes:
  • Using GPIO.IN instead of GPIO.OUT
  • Calling GPIO.output() to set mode
  • Misusing GPIO.setmode() for pin setup

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes