Bird
0
0

Which of the following is the correct Python syntax to set a PWM frequency to 1000 Hz on a Raspberry Pi GPIO pin using RPi.GPIO?

easy📝 Syntax Q12 of 15
Raspberry Pi - PWM Output
Which of the following is the correct Python syntax to set a PWM frequency to 1000 Hz on a Raspberry Pi GPIO pin using RPi.GPIO?
Apwm = GPIO.PWM(pin, 1000)
Bpwm = GPIO.setPWM(pin, 1000)
Cpwm = GPIO.PWM(pin).frequency(1000)
Dpwm = GPIO.frequency(pin, 1000)
Step-by-Step Solution
Solution:
  1. Step 1: Recall RPi.GPIO PWM syntax

    The correct way to create a PWM instance is GPIO.PWM(pin, frequency).
  2. Step 2: Check options for correct method and parameters

    pwm = GPIO.PWM(pin, 1000) matches the correct syntax; others use invalid methods or chaining.
  3. Final Answer:

    pwm = GPIO.PWM(pin, 1000) -> Option A
  4. Quick Check:

    GPIO.PWM(pin, freq) creates PWM [OK]
Quick Trick: Use GPIO.PWM(pin, frequency) to set PWM frequency [OK]
Common Mistakes:
  • Using non-existent methods like setPWM or frequency()
  • Trying to set frequency after creating PWM without parameters
  • Confusing method chaining syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes