Bird
0
0

Identify the error in this code that tries to set LED brightness:

medium📝 Debug Q14 of 15
Raspberry Pi - gpiozero Library
Identify the error in this code that tries to set LED brightness:
from gpiozero import PWMLED
led = PWMLED(18)
led.brightness(0.7)
AUsing parentheses after brightness instead of assignment
BWrong pin number for PWMLED
CMissing import for time module
DPWMLED does not support brightness control
Step-by-Step Solution
Solution:
  1. Step 1: Check how brightness is set

    Brightness is an attribute, so it should be assigned a value, not called like a function.
  2. Step 2: Verify other options

    Pin 18 is valid, time module is not needed here, and PWMLED supports brightness.
  3. Final Answer:

    Using parentheses after brightness instead of assignment -> Option A
  4. Quick Check:

    brightness is attribute, not method = D [OK]
Quick Trick: Set brightness with =, not parentheses [OK]
Common Mistakes:
  • Calling brightness like a function
  • Assuming pin number causes error
  • Thinking time import is required here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes