Bird
0
0

You want to read a button press on pin 10 and turn on an LED on pin 11 when pressed. Which code correctly sets the pin modes?

hard📝 Application Q15 of 15
Raspberry Pi - GPIO Basics with Python
You want to read a button press on pin 10 and turn on an LED on pin 11 when pressed. Which code correctly sets the pin modes?
AGPIO.setup(10, GPIO.OUT) GPIO.setup(11, GPIO.IN)
BGPIO.setup(10, GPIO.IN) GPIO.setup(11, GPIO.IN)
CGPIO.setup(10, GPIO.IN) GPIO.setup(11, GPIO.OUT)
DGPIO.setup(10, GPIO.OUT) GPIO.setup(11, GPIO.OUT)
Step-by-Step Solution
Solution:
  1. Step 1: Determine pin roles

    Pin 10 reads button input, so it must be input mode.
  2. Step 2: Set LED pin mode

    Pin 11 controls LED output, so it must be output mode.
  3. Final Answer:

    GPIO.setup(10, GPIO.IN) GPIO.setup(11, GPIO.OUT) -> Option C
  4. Quick Check:

    Input pin for button, output pin for LED [OK]
Quick Trick: Input for button pin, output for LED pin [OK]
Common Mistakes:
  • Reversing input and output pins
  • Setting both pins as input
  • Setting both pins as output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes