【OpenMV学习笔记】OpenMV控制单个PWM舵机

 代码:

注意的地方是openmv3 P7-9是pwm口,

angle(参数),参数是绝对角度。

# Servo Control Example
#
# This example shows how to use your OpenMV Cam to control servos.

import time
from pyb import Servo

s1 = Servo(1) # P7
s2 = Servo(2) # P8
#s3 = Servo(3) # P9 Only for OpenMV3 M7
while(True):
    for i in range(-90,90):
        s1.angle(i)
        s2.angle(i)
        time.sleep(10)
    for i in range(90,-90):
        s1.angle(i)
        s2.angle(i)
        time.sleep(10)

 连线:一定要外部电源供电

【OpenMV学习笔记】OpenMV控制单个PWM舵机_第1张图片

你可能感兴趣的:(openmv)