Bird
0
0

Which Python command correctly initializes PWM on GPIO pin 18 at a frequency of 1000 Hz using the RPi.GPIO library?

easy📝 Syntax Q3 of 15
Raspberry Pi - PWM Output
Which Python command correctly initializes PWM on GPIO pin 18 at a frequency of 1000 Hz using the RPi.GPIO library?
Apwm = GPIO.PWM(1000, 18)
Bpwm = GPIO.PWM(18, 1000)
Cpwm = GPIO.setup(18, GPIO.PWM(1000))
Dpwm = GPIO.startPWM(18, 1000)
Step-by-Step Solution
Solution:
  1. Step 1: Check RPi.GPIO PWM syntax

    The correct syntax is GPIO.PWM(pin_number, frequency).
  2. Step 2: Match parameters

    Pin 18 and frequency 1000 Hz must be in that order.
  3. Final Answer:

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

    Is pin first and frequency second? Yes. [OK]
Quick Trick: GPIO.PWM(pin, frequency) initializes PWM [OK]
Common Mistakes:
  • Swapping pin and frequency arguments
  • Using setup() instead of PWM()
  • Calling non-existent startPWM() function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes