Skip to content

Instantly share code, notes, and snippets.

@rtyley
Created June 29, 2022 09:37
Show Gist options
  • Save rtyley/5bf3564ba6f10f9fadb4f21c277848fe to your computer and use it in GitHub Desktop.
Save rtyley/5bf3564ba6f10f9fadb4f21c277848fe to your computer and use it in GitHub Desktop.
import board
import adafruit_aw9523 # LED driver
from time import sleep
i2c = board.I2C()
aw = adafruit_aw9523.AW9523(i2c)
aw.constant_current_range = adafruit_aw9523.AW9523_2_4_RANGE
aw.LED_modes = 0xFFFF
aw.directions = 0xFFFF
sleep(3)
while True:
for level in [1, 2, 128, 255]:
print(f"level = {level}")
for rangeId in [adafruit_aw9523.AW9523_4_4_RANGE,adafruit_aw9523.AW9523_3_4_RANGE,adafruit_aw9523.AW9523_2_4_RANGE,adafruit_aw9523.AW9523_1_4_RANGE]:
aw.constant_current_range = rangeId
aw.set_constant_current(1, level) # setting `constant_current_range` only takes effect after this is called.
print(f"constant_current_range = {rangeId}")
sleep(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment