/ 3D_Printed_Guardian_Sword / code.py
code.py
1 # SPDX-FileCopyrightText: 2018 Mikey Sklar for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 # 3D_Printed_Guardian_Sword 6 # https://learn.adafruit.com/breath-of-the-wild-guardian-sword-led-3d-printed 7 8 import time 9 10 import board 11 import neopixel 12 13 pin = board.D4 # DIGITAL IO pin for NeoPixel OUTPUT from GEMMA 14 pixel_count = 93 # number of neopixels 15 delayval = .01 # 10 ms delay 16 17 APIXELS = 14 # number of first orange pixels 18 BPIXELS = 84 # number of blue pixels 19 CPIXELS = 93 # second orange pixels 20 21 # initialize neopixels 22 pixels = neopixel.NeoPixel(pin, pixel_count, brightness=1, auto_write=False) 23 24 while True: 25 26 # For the first 14 pixels, make them orange, 27 # starting from pixel number 0. 28 for i in range(0, APIXELS): 29 # Set Pixels to Orange Color 30 pixels[i] = (255, 50, 0) 31 # This sends the updated pixel color to the hardware. 32 pixels.write() 33 # Delay for a period of time (in milliseconds). 34 time.sleep(delayval) 35 36 # Fill up 84 pixels with blue, 37 # starting with pixel number 14. 38 for i in range(APIXELS, BPIXELS): 39 # Set Pixels to Orange Color 40 pixels[i] = (0, 250, 200) 41 # This sends the updated pixel color to the hardware. 42 pixels.write() 43 # Delay for a period of time (in milliseconds). 44 time.sleep(delayval) 45 46 # Fill up 9 pixels with orange, 47 # starting from pixel number 84. 48 for i in range(BPIXELS, CPIXELS): 49 # Set Pixels to Orange Color 50 pixels[i] = (250, 50, 0) 51 # This sends the updated pixel color to the hardware. 52 pixels.write() 53 # Delay for a period of time (in milliseconds). 54 time.sleep(delayval)