Pan and Tilt Shield¶
Pan and Tilt Shield 為 OpenMV Cam 提供三個伺服通道,並搭配 NCP1117 5 V 線性穩壓器,可從單一 6.5–18 V 電池輸入同時為相機與伺服馬達供電。
完整的資料手冊、照片與訂購資訊請參閱 Pan and Tilt Shield 產品頁面。
特色亮點¶
三個獨立的伺服通道
可與 Servo Shield 堆疊
接腳配置¶
接腳參考¶
接腳 |
功能 |
|---|---|
P7 |
伺服 0(S0) |
P8 |
伺服 1(S1) |
P9 |
伺服 2(S2) |
VBAT 輸入 |
螺絲端子上的 6.5–18 V 電池輸入(NCP1117 限制) |
VIN 輸出 |
來自板載 NCP1117 的 5 V 穩壓輸出 — 同時為相機與伺服電源軌供電 |
GND 電源軌 |
伺服與相機的共同接地 |
使用方式¶
以 50 Hz PWM 驅動三個伺服通道。脈衝寬度範圍因伺服馬達而異,因此請調整 MIN_US 與 MAX_US 以符合你的伺服馬達 — 典型值約為 1000–2000 µs:
from machine import Pin, PWM
import time
MIN_US = 1000 # full-left pulse width (microseconds)
MAX_US = 2000 # full-right pulse width
pan = PWM(Pin("P7"), freq=50) # S0
tilt = PWM(Pin("P8"), freq=50) # S1
aux = PWM(Pin("P9"), freq=50) # S2
def angle(servo, deg):
pulse_us = MIN_US + (deg * (MAX_US - MIN_US)) // 180
servo.duty_ns(pulse_us * 1000)
while True:
angle(pan, 0)
angle(tilt, 90)
time.sleep(1)
angle(pan, 180)
angle(tilt, 45)
time.sleep(1)