Last active
October 7, 2018 04:01
-
-
Save raspberrypisig/959662ec1482fa109f87772f76a7ccea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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