Example: 50-OpenMV-Boards/60-Shields/61-Servo-Shield/main.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 舵机扩展板示例。
#
# 此示例演示了舵机扩展板的使用。请按照以下步骤操作:
#
#   1. Connect a servo to any PWM output.
#   2. Connect a 3.7v battery (or 5V source) to VIN and GND.
#   3. Copy pca9685.py and servo.py to OpenMV and reset it.
#   4. Connect and run this script in the IDE.

import time
from servo import Servos
from machine import SoftI2C, Pin

i2c = SoftI2C(sda=Pin("P5"), scl=Pin("P4"))
servo = Servos(i2c, address=0x40, freq=50, min_us=650, max_us=2800, degrees=180)

while True:
    for i in range(0, 8):
        servo.position(i, 0)
    time.sleep_ms(500)
    for i in range(0, 8):
        servo.position(i, 180)
    time.sleep_ms(500)

results matching ""

    No results matching ""