|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# ==================================================================== # DISCLAIMER: # This code is provided as-is for educational and experimental # purposes only. The author makes no representations or warranties of # any kind concerning the safety, suitability, or accuracy of this # code. Use at your own risk. The author assumes no liability for any # damages, system failures, security breaches, or network issues # resulting from the use or implementation of this script. # ==================================================================== import time import board import neopixel_spi as neopixel import colorsys import math def hsv2rgb(h): r, g, b = colorsys.hsv_to_rgb(h, 1, 1) return (int(r*255),int(g*255),int(b*255)) spi = board.SPI() LED_COUNT = 12 PO = neopixel.GRB strip = neopixel.NeoPixel_SPI(spi, LED_COUNT,pixel_order=PO, auto_write = False) strip.fill(0) strip.show() strip[0] = (255,0,0) strip.show() ts=.1 time.sleep(ts) strip[1] = (0,255,0) strip.show() time.sleep(ts) strip[2] = (0,0,255) strip.show() time.sleep(.1) strip[3] = (0,255,255) strip.show() time.sleep(ts) strip[4] = (255,0,255) strip.show() time.sleep(.1) strip[5] = (255,255,0) strip.show() time.sleep(.1) strip[6] = (255,100,0) strip.show() time.sleep(ts) strip[7] = (128,0,255) strip.show() time.sleep(.1) strip[8] = (0,255,128) strip.show() time.sleep(.1) strip[9] = (255,0,128) strip.show() time.sleep(ts) strip[10] = (128,255,0) strip.show() time.sleep(ts) strip[11] = (0,128,255) strip.show() time.sleep(.1) ts2=5 for i in range(5): strip.fill((255,0,0)) strip.show() time.sleep(ts2) strip.fill((0,0,255)) strip.show() time.sleep(ts2) strip.fill((255,0,0)) strip.show() ts3=1 time.sleep(ts3) ts4=.3 for lap in range(3): for i in range(12): strip[i] = (0,255,0) strip.show() time.sleep(ts4) strip[i] = (255,0,0) strip.fill((40,0,0)) strip.show() time.sleep(ts3) for lap in range(4): for i in range(12): greenPos = i bluePos = (i + 6)%12 strip[greenPos] = (0,255,0) strip[bluePos] = (0,0,255) strip.show() time.sleep(ts4) strip[greenPos] = (40,0,0) strip[bluePos] = (40,0,0) for laps in range(6): for step in range(360): brightness= (math.sin(step*3.1415/180)+1)/2 r = 0 g = int(255*brightness) b = int(50*brightness) strip.fill((r,g,b)) strip.show() time.sleep(.005) for laps in range(5): for step in range(100): hue = step/100 color = hsv2rgb(hue) strip.fill(color) strip.show() time.sleep(ts) strip.fill(0) strip.show() |
In this class we are using this as our standard components. You should already have the core circuit built and should already have the OLED connected. Today you will add the NeoPixel array.
Our core circuit is:

Last week we also added the SSD1306 OLED Display.

And finally today we add the NeoPixel ring from the Fusion AI Lab Kit.
