Pan and Tilt Shield

Il Pan and Tilt Shield fornisce all’OpenMV Cam tre canali servo con un regolatore lineare a 5 V NCP1117 che alimenta sia la camera sia i servo da un singolo ingresso a batteria 6.5–18 V.

Pan and Tilt Shield

Per il datasheet completo, le foto e gli ordini consulta la pagina prodotto del Pan and Tilt Shield.

Punti salienti

  • Tre canali servo indipendenti

  • Impilabile con il Servo Shield

Pinout

Pinout del Pan and Tilt Shield

Riferimento dei pin

Pin

Funzione

P7

Servo 0 (S0)

P8

Servo 1 (S1)

P9

Servo 2 (S2)

VBAT in

Ingresso a batteria 6.5–18 V sul morsetto a vite (limiti dell’NCP1117)

VIN out

5 V regolati dall’NCP1117 on-board — alimenta sia la camera sia la linea dei servo

Linea GND

Massa comune di servo e camera

Utilizzo

Comanda i tre canali servo con PWM a 50 Hz. L’intervallo di larghezza dell’impulso varia tra i servo, quindi regola MIN_US e MAX_US per adattarli ai tuoi — i valori tipici sono intorno a 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)