Bird
0
0

What will be the brightness level of the LED after running this code snippet?

medium📝 Predict Output Q4 of 15
Raspberry Pi - PWM Output
What will be the brightness level of the LED after running this code snippet?
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
pwm = GPIO.PWM(18, 1000)
pwm.start(75)
ALED will be at 25% brightness
BLED will be off
CLED will be at 75% brightness
DCode will cause a runtime error
Step-by-Step Solution
Solution:
  1. Step 1: Understand pwm.start() parameter

    The start method's argument is duty cycle percentage; 75 means 75% on time.
  2. Step 2: Relate duty cycle to brightness

    75% duty cycle means LED is on 75% of the time, so brightness is 75%.
  3. Final Answer:

    LED will be at 75% brightness -> Option C
  4. Quick Check:

    Duty cycle 75% = 75% brightness [OK]
Quick Trick: Duty cycle % equals LED brightness % [OK]
Common Mistakes:
  • Confusing duty cycle with off time
  • Assuming LED is off if duty cycle < 100
  • Expecting runtime error without cause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes