提交 3832cf36 authored 作者: 唐睿骞's avatar 唐睿骞

增加舵机库及示例

上级 f0e57c55
from machine import Pin, PWM
class SERVO:
def __init__(self, pin):
self.pin = pin
self.pwm = PWM(self.pin)
def turn(self, val):
self.pwm.freq(100)
self.pwm.duty_u16(int(val/180*13000+4000))
\ No newline at end of file
from machine import Pin
from servo import SERVO
from time import sleep
servo = SERVO(Pin(27))
a = 180
while True:
a = a == 0 and 180 or a - 1
servo.turn(a)
sleep(0.1)
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论