Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AHSPC/DRV8833_micropython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

17 Commits

Repository files navigation

DRV8833

Pure MicroPython driver for the DRV8833 motor driver (intended for Adafruit's breakout board, but should work with any).

For a similar (and more thorough) driver but written in CircuitPython, see adafruit_circuitpython_motor.

Example usage (tested with an RPI Pico):

from machine import Pin, PWM
from drv8833 import DRV8833
from time import sleep
Pin("LED").on()
sleep(1)
Pin("LED").off()
# NOTE: feel free to play with the frequency value! The frequency (how many PWM cycles per second
# sent to the DRV pins) changes the behavior of the connected motors, especially at low throttle
# values. (based on very brief testing) We recommend values no lower than 1,000 and no higher than
# 200,000. 40,000 is a good default.
frequency = 40_000
# Make sure to set the correct pins!
ain1 = PWM(Pin(15, Pin.OUT))
ain2 = PWM(Pin(14, Pin.OUT))
bin1 = PWM(Pin(13, Pin.OUT))
bin2 = PWM(Pin(12, Pin.OUT))
ain1.freq(frequency)
ain2.freq(frequency)
bin1.freq(frequency)
bin2.freq(frequency)
drv = DRV8833(ain1, ain2, bin1, bin2)
throttle = 1.0
while throttle > -1.0:
 drv.throttle_a(throttle)
 drv.throttle_b(throttle)
 sleep(0.1)
 throttle -= 0.05
 print(throttle)
drv.stop_a()
drv.stop_b()
# This will be called automatically when DRV8833 object leaves scope, but can be called manually if you want
# drv.deinit()

About

MicroPython library for the DRV8833 motor driver.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /