Skip to main content

A port of Grove Motor Driver TB6612FNG library for python and RaspberryPI. This library also includes easing functions to control your motors with smooth transitions.Easing functions are available for dc motors only.

Project description

RaspberryPi Grove TB6612FNG Motor Shield Library

PyPI pyversions PyPI version shields.io PyPI license Codacy Badge

This is an open source port of the official Grove Motor Shield TB6612FNG library for Arduino to Python3 on RaspberryPI.

This is a port of Grove Arduino Library for Grove I2C Motor Driver on TB6612FNG.

Features

  • Library is identical to the official Grove
  • It depends only on built in libraries**

**library requires I2C to be activated on the RaspberryPI board running Linux build

Requirements

  • RaspberryPi linux image
  • Python 3.6+
  • smbus library
  • time library
  • math library

This library also includes a experimental python easing functions:

  • Contains 6 easing functions for smooth start of motors
  • Easing functions currently can only be used on a single motor at once
  • Containing IN and OUT functions

How to use

Basic usage of this library is very simple. First make sure you are running the latest released version of pip.

This library requires you to add an additional index-url to pip.conf in order to install it. You can do this by editing your config file with sudo nano /etc/pip.conf and inserting this line just after the [global] section:

index-url=https://pypi.python.org/

Now you can install the package as usual, for python3 use something for example: python3 -m pip install raspberry-i2c-tb6612fng

Next, after successful instalation you can import this library and start using it in your project like this:

# import default libraries that are used in this example
import time

# import the library
from raspberry_i2c_tb6612fng import MotorDriverTB6612FNG, TB6612FNGMotors

# create an instance of the driver, connected to i2c
driver = MotorDriverTB6612FNG()

# drive both motors forward
driver.dc_motor_run(TB6612FNGMotors.MOTOR_CHA, 200)
driver.dc_motor_run(TB6612FNGMotors.MOTOR_CHB, 200)

# pause for a second
time.sleep(1)

# stop the motors
driver.dc_motor_break(TB6612FNGMotors.MOTOR_CHA)
driver.dc_motor_break(TB6612FNGMotors.MOTOR_CHB)
Documentation

If you would like to read about all functions available, please refer to this projects Wiki page on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raspberry-i2c-tb6612fng-0.2.0.tar.gz (18.9 kB view hashes)

Uploaded Source

Built Distribution

raspberry_i2c_tb6612fng-0.2.0-py3-none-any.whl (20.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page