樹莓派PWM

import RPi.GPIO as GPIO
import time


GPIO.setmode(GPIO.BCM)

GPIO.setup(26, GPIO.OUT)
  
p = GPIO.PWM(26, 100) #100 是頻率
p.start(10)     # p.start(dc)  dc 表明佔空比 0.0 ~ 100.0

try:
    while 1:

            time.sleep(0.1)
except KeyboardInterrupt:
    pass
p.stop()
GPIO.cleanup()