/ Glowing_Scale_Armor / code.py
code.py
1 # SPDX-FileCopyrightText: 2019 Erin St Blaine for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 """ Simple FancyLED example for NeoPixel strip 6 """ 7 8 import board 9 import neopixel 10 import adafruit_fancyled.adafruit_fancyled as fancy 11 12 num_leds = 17 13 14 # Declare a Water Colors palette 15 palette = [fancy.CRGB(0, 214, 214), # blues and cyans 16 fancy.CRGB(0, 92, 160), 17 fancy.CRGB(0, 123, 255), 18 fancy.CRGB(0, 68, 214)] 19 20 # Declare a Fire Colors palette 21 #palette = [fancy.CRGB(0, 0, 0), # Black 22 # fancy.CHSV(1.0), # Red 23 # fancy.CRGB(1.0, 1.0, 0.0), # Yellow 24 # 0xFFFFFF] # White 25 26 # Declare a NeoPixel object on pin D6 with num_leds pixels, no auto-write. 27 # Set brightness to max because we'll be using FancyLED's brightness control. 28 pixels = neopixel.NeoPixel(board.D1, num_leds, brightness=1.0, 29 auto_write=False) 30 31 offset = 0 # Positional offset into color palette to get it to 'spin' 32 33 while True: 34 for i in range(num_leds): 35 # Load each pixel's color from the palette using an offset, run it 36 # through the gamma function, pack RGB value and assign to pixel. 37 color = fancy.palette_lookup(palette, offset + i / num_leds) 38 color = fancy.gamma_adjust(color, brightness=0.25) 39 pixels[i] = color.pack() 40 pixels.show() 41 42 offset += 0.02 # Bigger number = faster spin