Bird
0
0

Which of the following is the correct way to set up a GPIO pin 17 as an output for the LED in Python using RPi.GPIO?

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

Which of the following is the correct way to set up a GPIO pin 17 as an output for the LED in Python using RPi.GPIO?

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
# What goes here?
AGPIO.setup(17, GPIO.OUT)
BGPIO.setup(17, GPIO.IN)
CGPIO.output(17, GPIO.OUT)
DGPIO.input(17, GPIO.OUT)
Step-by-Step Solution
Solution:
  1. Step 1: Identify the function to configure pin mode

    GPIO.setup(pin_number, mode) is used to set a pin as input or output.
  2. Step 2: Set pin 17 as output

    Use GPIO.setup(17, GPIO.OUT) to configure pin 17 as an output for the LED.
  3. Final Answer:

    GPIO.setup(17, GPIO.OUT) -> Option A
  4. Quick Check:

    GPIO.setup with GPIO.OUT sets output pin = A [OK]
Quick Trick: Use GPIO.setup(pin, GPIO.OUT) for output pins [OK]
Common Mistakes:
  • Using GPIO.setup with GPIO.IN for output pin
  • Confusing GPIO.output with GPIO.setup
  • Using GPIO.input for output pin setup

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes