adafruit_motorkit

CircuitPython helper library for DC & Stepper Motor FeatherWing, Shield, and Pi Hat kits.

  • Author(s): Scott Shawcroft, Kattni Rembor

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_motorkit.MotorKit(address: int = 96, i2c: Optional[I2C] = None, steppers_microsteps: int = 16, pwm_frequency: float = 1600.0)

Class representing an Adafruit DC & Stepper Motor FeatherWing, Shield or Pi Hat kit.

Parameters
  • address (int) – I2C address of PCA9685 PWM controller. Default address is 0x60.

  • i2c (busio.I2C) –

    I2C bus object to use. If not specified, use board.I2C().

    Note

    board.I2C() uses the default I2C bus frequency of 100 kHz. To speed up motor control, use an I2C bus frequency of 400 KHz, or if available, 1 MHz. The PCA9685 controller supports both of these higher speeds. This will noticeably speed up stepper motor operation when many steps are requested.

  • steppers_microsteps (int) – Number of microsteps per step for stepper motors. Default is 16.

  • pwm_frequency (float) – defaults to 1600 Hz

property frequency: float

The overall PCA9685 PWM frequency in Hertz.

property motor1: DCMotor

:py:class:~adafruit_motor.motor.DCMotor controls for motor 1.

The following image shows the location of the M1 terminal on the DC/Stepper FeatherWing. The label on the FeatherWing is found on the bottom of the board. The terminal is labeled on the top of the Shield and Pi Hat.

Motor 1 location

This example moves the motor forwards for one fifth of a second at full speed.

import time
from adafruit_motorkit import motorkit

kit = MotorKit()

kit.motor1.throttle = 1.0
time.sleep(0.2)

kit.motor1.throttle = 0
property motor2: DCMotor

:py:class:~adafruit_motor.motor.DCMotor controls for motor 2.

The following image shows the location of the M2 terminal on the DC/Stepper FeatherWing. The label on the FeatherWing is found on the bottom of the board. The terminal is labeled on the top of the Shield and Pi Hat.

Motor 2 location

This example moves the motor forwards for one fifth of a second at full speed.

import time
from adafruit_motorkit import motorkit

kit = MotorKit()

kit.motor2.throttle = 1.0
time.sleep(0.2)

kit.motor1.throttle = 0
property motor3: DCMotor

:py:class:~adafruit_motor.motor.DCMotor controls for motor 3.

The following image shows the location of the M2 terminal on the DC/Stepper FeatherWing. The label on the FeatherWing is found on the bottom of the board. The terminal is labeled on the top of the Shield and Pi Hat.

Motor 3 location

This example moves the motor forwards for one fifth of a second at full speed.

import time
from adafruit_motorkit import motorkit

kit = MotorKit()

kit.motor3.throttle = 1.0
time.sleep(0.2)

kit.motor1.throttle = 0
property motor4: DCMotor

:py:class:~adafruit_motor.motor.DCMotor controls for motor 4.

Motor 4 location

This example moves the motor forwards for one fifth of a second at full speed.

import time
from adafruit_motorkit import motorkit

kit = MotorKit()

kit.motor4.throttle = 1.0
time.sleep(0.2)

kit.motor1.throttle = 0
property stepper1: StepperMotor

:py:class:~adafruit_motor.stepper.StepperMotor controls for one connected to stepper 1 (also labeled motor 1 and motor 2).

The following image shows the location of the stepper1 terminals on the DC/Stepper FeatherWing. stepper1 is made up of the M1 and M2 terminals. The labels on the FeatherWing are found on the bottom of the board. The terminals are labeled on the top of the Shield and Pi Hat.

Stepper 1 location

This example moves the stepper motor 100 steps forwards.

from adafruit_motorkit import MotorKit

kit = MotorKit()

for i in range(100):
    kit.stepper1.onestep()
property stepper2: StepperMotor

:py:class:~adafruit_motor.stepper.StepperMotor controls for one connected to stepper 2 (also labeled motor 3 and motor 4).

The following image shows the location of the stepper2 terminals on the DC/Stepper FeatherWing. stepper2 is made up of the M3 and M4 terminals. The labels on the FeatherWing are found on the bottom of the board. The terminals are labeled on the top of the Shield and Pi Hat.

Stepper 2 location

This example moves the stepper motor 100 steps forwards.

from adafruit_motorkit import MotorKit

kit = MotorKit()

for i in range(100):
    kit.stepper2.onestep()