Skip to content
Snippets Groups Projects
Select Git revision
  • c8b60f013b9d624a74ad502460f2bc7d00c39644
  • wip-bootstrap default
  • dualcore
  • ch3/leds
  • ch3/time
  • master
6 results

ACKNOWLEDGEMENTS

Blame
  • 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