Bird
0
0

Which of the following is the correct way to start PWM on pin 18 with a frequency of 1000 Hz using RPi.GPIO?

easy📝 Syntax Q12 of 15
Raspberry Pi - PWM Output
Which of the following is the correct way to start PWM on pin 18 with a frequency of 1000 Hz using RPi.GPIO?
Apwm = GPIO.PWM(1000, 18); pwm.start(50)
Bpwm = GPIO.PWM(18); pwm.start(1000)
Cpwm = GPIO.PWM(18, 1000); pwm.start(50)
Dpwm = GPIO.PWM(18, 50); pwm.start(1000)
Step-by-Step Solution
Solution:
  1. Step 1: Check PWM constructor parameters

    The PWM constructor takes pin number first, then frequency in Hz, so GPIO.PWM(18, 1000) is correct.
  2. Step 2: Verify start method usage

    The start method takes duty cycle percentage, so pwm.start(50) starts PWM at 50% duty cycle.
  3. Final Answer:

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

    Pin, frequency order + start with duty cycle = A [OK]
Quick Trick: PWM(pin, freq), then start(duty cycle) [OK]
Common Mistakes:
  • Swapping frequency and pin arguments
  • Passing duty cycle to PWM constructor
  • Using start() with frequency instead of duty cycle

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes