Reference

class adafruit_motor_hat.MotorHat.AdafruitStepperMotor(controller, num, steps=200)[source]
align_step(reverse=False)[source]

Align the current step position with a full step :param reverse:

run in reverse
Returns:None
double_step(steps=1, reverse=False)[source]

Double stepping, 2 coils at once :param steps:

The number of steps to execute
Parameters:reverse (bool) – step in reverse
Returns:None
interleaved_step(steps=1, reverse=False)[source]

Interleaved stepping, single stepping and interleaved stepping :param steps:

The number of steps to execute
Parameters:reverse (bool) – step in reverse
Returns:None
micro_step(steps=1, reverse=False)[source]

Microstepping :param steps:

The number of steps to execute
Parameters:reverse (bool) – step in reverse
Returns:None
set_speed(rpm)[source]

Set the target motor speed in rpm, motor step count is used to calculate the step delay :param rpm:

Target RPM
Returns:None
step(steps=1, reverse=False)[source]

Simple single step :param steps:

The number of steps to execute
Parameters:reverse (Bool) – step in reverse
Returns:None
class adafruit_motor_hat.MotorHat.AdafruitDCMotor(controller, num)[source]
class adafruit_motor_hat.MotorHat.AdafruitMotorHAT(addr=96, freq=1600, i2c=None, i2c_bus=None)[source]
get_motor(num)[source]

Get a motor instance :param num:

the stepper to get 1-4
Returns::class:`AdafruitDCMotor’
get_stepper(num)[source]

Get a stepper instance :param num:

the stepper to get 1, or 2
Returns::class:`AdafruitStepperMotor’
set_pin(pin, value)[source]

Set a pin output state :param pin:

pin number
Parameters:value (int) – pin state 0, or 1
Returns:None
class adafruit_motor_hat.Adafruit_PWM_Servo_Driver.PWM(address=64, debug=False, i2c=None, i2c_bus=None)[source]

Adafruit PCA9685 16-Channel PWM Servo Driver

setAllPWM(on, off)[source]

Sets all the pwm outputs to the corresponding outputs

Parameters:
  • on – the portion of the PWM period in 1/4096ths of a period (0 corresponds to the start, 4096 corresponds to the end) to wait before the signal turns on
  • off – the portion of the PWM period in 1/4096ths of a period (0 corresponds to the start, 4096 corresponds to the end) to wait before the signal turns off
Returns:

None

setPWM(channel, on, off)[source]

Set a single pwm channel

Parameters:
  • channel – the channel number from 0-15 inclusive
  • on – the portion of the PWM period in 1/4096ths of a period (0 corresponds to the start, 4096 corresponds to the end) to wait before the signal turns on
  • off – the portion of the PWM period in 1/4096ths of a period (0 corresponds to the start, 4096 corresponds to the end) to wait before the signal turns off
Returns:

None

setPWMFreq(freq)[source]

Set the PWM frequency in Hz

Parameters:freq (int) – frequency in Hz
Returns:None
classmethod softwareReset(i2c=None, i2c_bus=None)[source]

Sends a software reset (SWRST) command to all the servo drivers on the bus

adafruit_motor_hat.Adafruit_PWM_Servo_Driver.get_i2c_device(address, i2c, i2c_bus)[source]

Helper method to get a device at the specified address from the I2C bus. If no i2c bus is specified (i2c param is None) then the default I2C bus for the platform will be used.

Parameters:
  • address (hex) – i2c address to get the handle for
  • i2c – GPIO i2c class, None to use the Adafruit_GPIO.I2C class
  • i2c_bus – i2c bus number, passed to busnum, none to autodetect
Returns:

i2c Address