2878| 0
|
BPI-PicoW-S3 PWM控制舵机[CircuitPython] |
BPI-PicoW-S3 PWM控制舵机[CircuitPython] BPI-Pico-S3 与 Raspberry Pi Pico 板尺寸相同,搭载ESP32S3芯片,8M flash,4层PCB,电镀半孔工艺,陶瓷天线,支持 2.4 GHz Wi-Fi 和 Bluetooth® LE 双模无线通信,是一款专为物联网开发和Maker DIY设计的开发板。 出厂内置 tinyUF2 + CircuitPython,推荐使用Mu编辑器上手CircuitPython开发。 BiliBili视频硬件接口示意图PWM控制舵机以MG90S舵机为例,其他各种舵机参考其对应的使用手册,在以下代码中修改相应的参数。
y=(2500-500)/180*x+500 y=(100*x+4500)/9
y=((50-10)/180*x+10)/100*65535 y=(4369*x+196605)/30
MG90S BPI-PicoW-S3 GND 棕色GND +5V 红色VBUS PWM 橙色GP0
import pwmio import time servo_1 = pwmio.PWMOut(board.GP0, frequency=200, duty_cycle=0)#200hz, one cycle 5000us def get_duty_cycle(x): return int((4369*x+196605)/30) servo_1.duty_cycle = get_duty_cycle(90)# 90 degrees
import pwmio import time servo_1 = pwmio.PWMOut(board.GP0, frequency=200, duty_cycle=0)#200hz, one cycle 5000us def get_duty_cycle(x): return int((4369*x+196605)/30) action_list1 = [0,45,90,135,180,0,180,45,135,90] while True: for i in action_list1: servo_1.duty_cycle = get_duty_cycle(i) time.sleep(0.5)购买BPI-PicoW-S3:
|
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed