Bird
0
0

What is wrong with this code snippet controlling PWM on Raspberry Pi?

medium📝 Debug Q7 of 15
Raspberry Pi - PWM Output
What is wrong with this code snippet controlling PWM on Raspberry Pi?
GPIO.setup(22, GPIO.OUT)
pwm = GPIO.PWM(22, 1000)
pwm.start(110)
APin 22 is not set as output
BDuty cycle cannot be greater than 100
CFrequency 1000 is too high
Dstart() method missing duty cycle
Step-by-Step Solution
Solution:
  1. Step 1: Check duty cycle limits

    Duty cycle must be between 0 and 100 percent.
  2. Step 2: Identify invalid duty cycle

    Value 110 exceeds 100, causing error or unexpected behavior.
  3. Final Answer:

    Duty cycle cannot be greater than 100 -> Option B
  4. Quick Check:

    Duty cycle max = 100% [OK]
Quick Trick: Duty cycle must be 0-100% inclusive [OK]
Common Mistakes:
  • Using duty cycle > 100
  • Assuming frequency limits cause error here
  • Forgetting to setup pin as output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes