mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
* Add Arduino UART example. * Update Arduino SPI example to use callbacks. * Remove printf from timer_control.py callback. * Add PWM channel 3 and servo 3 to pwm and servo examples.
23 lines
496 B
Python
23 lines
496 B
Python
# Servo Control Example
|
|
#
|
|
# This example shows how to use your OpenMV Cam to control servos.
|
|
|
|
import time
|
|
from pyb import Servo
|
|
|
|
s1 = Servo(1) # P7
|
|
s2 = Servo(2) # P8
|
|
s3 = Servo(3) # P9
|
|
|
|
while(True):
|
|
for i in range(1000):
|
|
s1.pulse_width(1000 + i)
|
|
s2.pulse_width(1999 - i)
|
|
s3.pulse_width(1000 + i)
|
|
time.sleep(10)
|
|
for i in range(1000):
|
|
s1.pulse_width(1999 - i)
|
|
s2.pulse_width(1000 + i)
|
|
s3.pulse_width(1999 - i)
|
|
time.sleep(10)
|