Skip to content
Snippets Groups Projects
Select Git revision
  • ed9c0185d80514670244b0c2147958dea00159a9
  • master default protected
2 results

pyb.Servo.rst

Blame
  • user avatar
    Paul Sokolovsky authored
    Class designator will be used as is in indexes, so must match actual class
    name.
    a384a531
    History
    pyb.Servo.rst 2.67 KiB

    class Servo -- 3-wire hobby servo driver

    Servo objects control standard hobby servo motors with 3-wires (ground, power, signal). There are 4 positions on the pyboard where these motors can be plugged in: pins X1 through X4 are the signal pins, and next to them are 4 sets of power and ground pins.

    Example usage:

    import pyb
    
    s1 = pyb.Servo(1)   # create a servo object on position X1
    s2 = pyb.Servo(2)   # create a servo object on position X2
    
    s1.angle(45)        # move servo 1 to 45 degrees
    s2.angle(0)         # move servo 2 to 0 degrees
    
    # move servo1 and servo2 synchronously, taking 1500ms
    s1.angle(-60, 1500)
    s2.angle(30, 1500)

    Note

    The Servo objects use Timer(5) to produce the PWM output. You can use Timer(5) for Servo control, or your own purposes, but not both at the same time.

    Constructors

    Create a servo object. id is 1-4, and corresponds to pins X1 through X4.

    Methods