Bird
0
0

What will be the output on the LED if the following Python code runs on a Raspberry Pi with an LED connected to GPIO pin 18?

medium📝 Predict Output Q13 of 15
Raspberry Pi - LED and Button Projects
What will be the output on the LED if the following Python code runs on a Raspberry Pi with an LED connected to GPIO pin 18?
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.output(18, GPIO.LOW)
AThe LED will turn OFF
BThe LED will blink
CThe code will cause an error
DThe LED will turn ON
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the GPIO setup

    Pin 18 is set as an output pin with GPIO.setup(18, GPIO.OUT).
  2. Step 2: Check the output value

    GPIO.output(18, GPIO.LOW) sets the pin to low voltage, turning the LED off.
  3. Final Answer:

    The LED will turn OFF -> Option A
  4. Quick Check:

    GPIO.LOW means LED off = D [OK]
Quick Trick: LOW means off, HIGH means on for LEDs [OK]
Common Mistakes:
  • Thinking LOW turns LED on
  • Assuming code blinks LED without loop
  • Expecting an error from correct code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes