code.py
1 # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries 2 # SPDX-License-Identifier: MIT 3 """ 4 NeoSlider NeoPixel Rainbow Demo 5 """ 6 import board 7 from rainbowio import colorwheel 8 from adafruit_seesaw.seesaw import Seesaw 9 from adafruit_seesaw.analoginput import AnalogInput 10 from adafruit_seesaw import neopixel 11 12 # NeoSlider Setup 13 neoslider = Seesaw(board.I2C(), 0x30) 14 potentiometer = AnalogInput(neoslider, 18) 15 pixels = neopixel.NeoPixel(neoslider, 14, 4, pixel_order=neopixel.GRB) 16 17 18 def potentiometer_to_color(value): 19 """Scale the potentiometer values (0-1023) to the colorwheel values (0-255).""" 20 return value / 1023 * 255 21 22 23 while True: 24 print(potentiometer.value) 25 # Fill the pixels a color based on the position of the potentiometer. 26 pixels.fill(colorwheel(potentiometer_to_color(potentiometer.value)))