树莓派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()
浙公网安备 33010602011771号