Basic Operation¶
examples/qwiic_pca9685_ex1.py¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import qwiic_pca9685
import time
import math
import sys
def runExample():
print("\nSparkFun BME280 Sensor Example 1\n")
mySensor = qwiic_pca9685.QwiicPCA9685()
if mySensor.isConnected() == False:
print("The Qwiic PCA9685 device isn't connected to the system. Please check your connection", \
file=sys.stderr)
return
mySensor.begin()
# Sets PWM Frequency to 50 Hz
mySensor.set_pre_scale(50)
# Sets start time of PWM pulse on Channel 0 to 0s
mySensor.set_channel_word(0, 1, 0)
while True:
# Increments start time of PWM pulse on Channel 0 to i (1ms to 2ms)
for i in range(205, 410):
fun.set_channel_word(0, 0, i)
# Delay .05 s
time.sleep(.05)
# Decrements start time of PWM pulse on Channel 0 to i (2ms to 1ms)
for i in range(410, 205, -1):
fun.set_channel_word(0, 0, i)
# Delay .05 s
time.sleep(.05)
time.sleep(1)
|