Bird
0
0

Which of the following is the correct way to start PWM on GPIO pin 18 at 50 Hz in Python using RPi.GPIO?

easy📝 Syntax Q12 of 15
Raspberry Pi - PWM Output
Which of the following is the correct way to start PWM on GPIO pin 18 at 50 Hz in Python using RPi.GPIO?
Apwm = GPIO.PWM(18, 50); pwm.start(7.5)
Bpwm = GPIO.PWM(50, 18); pwm.start(7.5)
Cpwm = GPIO.PWM(18); pwm.start(50)
Dpwm = GPIO.PWM(7.5, 18); pwm.start(50)
Step-by-Step Solution
Solution:
  1. Step 1: Check PWM initialization syntax

    GPIO.PWM(pin, frequency) initializes PWM on the specified pin and frequency.
  2. Step 2: Verify correct parameters

    Pin 18 and frequency 50 Hz are correct; start() takes duty cycle like 7.5.
  3. Final Answer:

    pwm = GPIO.PWM(18, 50); pwm.start(7.5) -> Option A
  4. Quick Check:

    GPIO.PWM(pin, freq) with start(duty) = B [OK]
Quick Trick: Remember GPIO.PWM(pin, freq) then start(duty) [OK]
Common Mistakes:
  • Swapping pin and frequency order
  • Missing frequency argument
  • Passing duty cycle in PWM() instead of start()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes