Skip to content

Instantly share code, notes, and snippets.

@raspberrypisig
Last active October 7, 2018 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raspberrypisig/959662ec1482fa109f87772f76a7ccea to your computer and use it in GitHub Desktop.
Save raspberrypisig/959662ec1482fa109f87772f76a7ccea to your computer and use it in GitHub Desktop.
# sudo apt install libffi-dev
# sudo pip install -U pip setuptools
# sudo pip install PCA9685-driver
from pca9685_driver import Device
from time import sleep
# 0x40 from i2cdetect -y 1 (1 if Raspberry pi 2)
dev = Device(0x40)
# set the duty cycle for LED05 to 50%
dev.set_pwm(0, 400)
# set the pwm frequency (Hz)
dev.set_pwm_frequency(50)
while True:
for i in range(200):
j = i + 200
dev.set_pwm(0, j)
sleep(0.01)
for i in range(200):
j = 400 - i
dev.set_pwm(0, j)
sleep(0.01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment