# SPDX-FileCopyrightText: Copyright (c) 2023 Jose D. Montoya
#
# SPDX-License-Identifier: MIT
from machine import Pin, I2C
import time
import pca9685
i2c = I2C(0, sda=Pin(16), scl=Pin(17)) # Correct I2C pins for RP2040
pca = pca9685.PCA9685(i2c)
pca.frequency = 50
# Set the PWM duty cycle for channel zero to 50%. duty_cycle is 16 bits to match other PWM objects
# but the PCA9685 will only actually give 12 bits of resolution.
while True:
for i in range(0, 181):
pca.channels[0].duty_cycle = i * 65
pca.channels[1].duty_cycle = i * 65
time.sleep_ms(10)
for i in range(180, 0, -1):
pca.channels[0].duty_cycle = i * 65
pca.channels[1].duty_cycle = i * 65
time.sleep_ms(10)