Getting started

Before you can get started coding, ensure you’ve performed all the steps in Installation, including the step about configuring udev.

You should also read the Pololu Maestro Servo Controller User’s Guide, as the concepts documented there correspond to functionality exposed through this Python module.

Assuming you’re getting started with a single controller, plug it in and try the following:

from maestro import Maestro

maestro = Maestro.get_one()

print("Maestro:", maestro)
print("Channel count:", maestro.channel_count)

You should get something like:

Maestro: <maestro.device.MiniMaestro "00262773">
Channel count: 12

The maestro.Meastro instance provides a list-like interface for accessing channels, so we can iterate over all the channels, or get one by index (starting at channel 0):

print("All channels:", list(maestro))
print("The third channel:", maestro[2])

And the result:

All channels: [<maestro.channel.Channel 0: Servo>, <maestro.channel.Channel 1: Servo>, <maestro.channel.Channel 2: Servo>, <maestro.channel.Channel 3: Servo>, <maestro.channel.Channel 4: Input>, <maestro.channel.Channel 5: Input>, <maestro.channel.Channel 6: Input>, <maestro.channel.Channel 7: Input>, <maestro.channel.Channel 8: Input>, <maestro.channel.Channel 9: Input>, <maestro.channel.Channel 10: Input>, <maestro.channel.Channel 11: Input>]
The third channel: <maestro.channel.Channel 2: Servo>

Using a channel as a servo

Note

To be continued…