EasyManua.ls Logo

Waveshare Motor Driver HAT - Python Demo Code

Waveshare Motor Driver HAT
16 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Motor Driver HAT
14 / 16
PYTHON
PROJECT DIRECTORY AND FILES
PCA9685.py is driver code, use I2C interface to output 16-channle PWM signals.
mian.py: Motor driver code
DEMO CODE
1. Instantiate PCA9685 library
pwm = PCA9685(0x40, debug=True)
Parameter 1: slave address of PCA9685, hardware configurable
Parameter 2: enable/disable debug information
pwm.setPWMFreq(50)
Set PWM frequency in range 40~1000
2. Initialize motors
class MotorDriver():
def __init__(self):
self.PWMA = 0
self.AIN1 = 1
self.AIN2 = 2

Related product manuals