Created
December 9, 2020 21:03
-
-
Save benevpi/16ca9ae7951be7672259a2bce9588534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Drive NeoPixels on the NeoPixels Block on Crickit for | |
# Circuit Playground Express | |
import time | |
import neopixel | |
import board | |
from adafruit_circuitplayground.express import cpx | |
from math import floor | |
num_pixels = 45 # Number of pixels driven from Crickit NeoPixel terminal | |
# The following line sets up a NeoPixel strip on Crickit CPX pin A1 | |
pixels = neopixel.NeoPixel(board.A1, num_pixels, brightness=0.2, | |
auto_write=False) | |
RED = (255, 0, 0) | |
YELLOW = (255, 150, 0) | |
GREEN = (0, 255, 0) | |
CYAN = (0, 255, 255) | |
BLUE = (0, 0, 255) | |
PURPLE = (180, 0, 255) | |
ORANGE = (200,100,0) | |
YELLOW = (150,150,0) | |
BLUE = (0,0,255) | |
INDIGO = (30,0,200) | |
VIOLET = (150,0,150) | |
RED1 = (255,0,0) | |
RED2 = (255,0,10) | |
RED25 = (255,0,50) | |
RED3 = (255,0,75) | |
RED35 = (200,0,100) | |
RED4 = (150,0,125) | |
blob = 0 | |
blob2 = 20 | |
while True: | |
pixels.fill(RED1) | |
for x in range(42): | |
if (x == (blob + 4)) or (x == (blob - 4)): | |
pixels[x] = RED2 | |
if (x == (blob + 3)) or (x == (blob - 3)): | |
pixels[x] = RED25 | |
if (x == (blob + 2)) or (x == (blob - 2)): | |
pixels[x] = RED3 | |
if x == blob + 1 or x == blob - 1: | |
pixels[x] = RED35 | |
if x == blob: | |
pixels[x] = RED4 | |
for x in range(42): | |
if (x == (blob2 + 4)) or (x == (blob2 - 4)): | |
pixels[x] = RED2 | |
if (x == (blob2 + 3)) or (x == (blob2 - 3)): | |
pixels[x] = RED25 | |
if (x == (blob2 + 2)) or (x == (blob2 - 2)): | |
pixels[x] = RED3 | |
if x == blob2 + 1 or x == blob2 - 1: | |
pixels[x] = RED35 | |
if x == blob2: | |
pixels[x] = RED4 | |
blob = blob+1 | |
if blob > 42: | |
blob=0 | |
blob2 = blob2+1 | |
if blob2 > 42: | |
blob2=0 | |
pixels.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment