Skip to content

Instantly share code, notes, and snippets.

@Nick-Harvey
Created July 15, 2022 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nick-Harvey/075fec0ea30a7a1d88f6683ce370eb97 to your computer and use it in GitHub Desktop.
Save Nick-Harvey/075fec0ea30a7a1d88f6683ce370eb97 to your computer and use it in GitHub Desktop.
import board
import neopixel
import time
import random
import argparse
num_pixels = 60
iterations = 2
pixels = neopixel.NeoPixel(board.D18, num_pixels)
def chase():
for j in range(iterations):
for q in range(3):
for i in range(0, num_pixels, 3):
pixels[i+q] = (0,0,255)
time.sleep(wait_ms / 1000.0)
for i in range(0, num_pixels, 3):
pixels[i+q] = (0,0,0)
def breath():
for j in range(iterations):
for a in range(0, 255, 5):
pixels.fill((0, 0, a))
time.sleep(0.05)
for a in range(255, -1, -5):
pixels.fill((0, 0, a))
time.sleep(0.05)
def twinkle():
for j in range(0, 1000):
p = random.randrange(0, num_pixels)
pixels[p] = (0, 0, 255)
pixels[p] = (0, 0, 0)
def lighttrail():
for j in range(iterations):
p = 0
pixels.fill((0, 0, 255))
for i in range(0, num_pixels):
pixels[p] = (255, 255, 255)
time.sleep(0.02)
pixels[p] = (0, 0, 255)
p += 1
def colorWipe():
pixels.fill((0, 0, 0))
if __name__ == '__main__':
# Process arguments
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--clear', action='store_true', help='clear the display on exit')
args = parser.parse_args()
try:
while True:
print('Running test')
breath()
twinkle()
print('Finished Twinkle')
lighttrail()
except:
if args.clear:
colorWipe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment