• 安装星瞳实验室APP,快速收到回复。扫描二维码或者点击 https://singtown.com/app/
  • 必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
  • 一个提问,一个帖子,标题为问题的介绍
  • 请贴出具体的代码,与报错提示。
  • 代码一定要让别人可以运行的文本,不要贴图片
  • 有小伙伴可以给我解释一下下面关于pca9685控制舵机的这段代码吗



    • # Servo Shield Example.
      #
      # This example demonstrates the servo shield. Please follow these steps:
      #
      #   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 I2C, Pin
      
      i2c = I2C(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(500)
          for i in range(0, 8):
              servo.position(i, 180)
          time.sleep(500)