The SparkFun moto:bit is a motor controller carrier for the BBC micro:bit. This board is also available as part of the SparkFun micro:bot kit.
SparkFun provides a MakeCode extension for using this board, but no driver for working with the board using micro:bit-flavored micropython. Given the spiffy new micro:bit Python Editor, it would nice to be able to program this motor controller in micropython. This class makes that easy to do.
The code has been moved to a new repo: https://github.com/stonehippo/micropython_motobit.
The Python Editor doesn't support loading modules (I think), so the easiest thing to do right now is copy and paste the class into the editor. The Python Editor supports creating additional files (in the Project
tab). My suggestion is to copy motobit.py
contents into a new file. Once that's done, it's pretty easy to get things going:
from motobit import Motobit
mb = Motobit()
mb.set_motor_speed(Motobit.RIGHT, 55)
mb.set_motor_speed(Motobit.LEFT, 55, reverse=True)
mb.enable() # turn on the motors, and go!
...
mb.disable() # turn the motors off
This code was based on the moto:bit PXT extension.