Code: Select all
import board
from neopixel import NeoPixel
from analogio import AnalogIn
from adafruit_led_animation.animation.chase import Chase
from adafruit_led_animation.animation.comet import Comet
from adafruit_led_animation.color import WHITE, PURPLE
import time
pixels = NeoPixel(board.D1, 60, brightness=1, auto_write=True)
pot = AnalogIn(board.A2)
chase = Chase(pixels, speed=0.1, color=WHITE, size=3, spacing=6)
comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
def show_colours(val):
if(val > 0 and val < 5):
comet.animate()
elif(val >= 5 and val <= 10):
chase.animate()
chase = Chase(pixels, speed=0.1, color=WHITE, size=3, spacing=6)
comet = Comet(pixels, speed=0.01, color=PURPLE, tail_length=10, bounce=True)
while True:
show_colours(int(pot.value/65520*10))
time.sleep(0.25)
print((pot.value))