Skip to content

Suitceyes-Project/PCA9685-Controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PCA9685-Controller

Provides a means of communicating with one or more PCA9685 boards from a Raspberry Pi.

Requirements

  • Raspberry Pi
  • PCA9685
  • Python 3

Installation

  • I2C communication needs to be activated on the Raspberry Pi. Follow this guide to do this.

  • The following python package also must be installed via this command:

    sudo pip3 install adafruit-circuitpython-pca9685

Example

To start a connection with the (or chained) PCA9685 board create an object with the following command:

from suitceyes import VibrationMotorDriver

# VibrationMotorDriver accepts a variable length of addresses of the i2c board.
with VibrationMotorDriver(0x41, 0x40) as driver:
    pass 

By using the with statement all vibrations are stopped once leaving the scope.

To trigger a vibration on a specific pin simply use the set_vibration(index, intensity) command. Intensity is a number between 0.0 and 1.0.

with VibrationMotorDriver(0x41, 0x40) as driver:
    # trigger vibration at index 16 (on board at address 0x40) at full intensity
    driver.set_vibration(16, 1.0)
    # wait one second 
    time.sleep(1)
    # trigger vibration at index 16 with half the intensity
    driver.set_vibration(16, 0.5)
    # wait one second 
    time.sleep(1)
    # mute vibration at index 16
    driver.set_vibration(16, 0.0)

Note that pins for the board at address 0x41 start at index 0 and go to index 15. Pins at address 0x40 then continue at pin 16 and go up to 31.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages