Bird
0
0

What will be the output brightness behavior if this code runs on a Raspberry Pi controlling an LED?

medium📝 Predict Output Q4 of 15
Raspberry Pi - PWM Output
What will be the output brightness behavior if this code runs on a Raspberry Pi controlling an LED?
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
pin = 18
GPIO.setup(pin, GPIO.OUT)
pwm = GPIO.PWM(pin, 1000)
pwm.start(25)
ALED will be dim with 25% brightness
BLED will be off
CLED will be fully bright
DCode will cause an error
Step-by-Step Solution
Solution:
  1. Step 1: Analyze PWM start duty cycle

    The pwm.start(25) sets duty cycle to 25%, so LED is ON 25% of the time.
  2. Step 2: Relate duty cycle to brightness

    25% duty cycle means LED brightness is about 25%, so dim but visible.
  3. Final Answer:

    LED will be dim with 25% brightness -> Option A
  4. Quick Check:

    Duty cycle 25% = Dim LED [OK]
Quick Trick: Duty cycle % = LED brightness % approximately [OK]
Common Mistakes:
  • Assuming LED is off at low duty cycle
  • Thinking LED is fully bright at 25%
  • Confusing frequency with brightness

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes