-
-
Save Nick-Harvey/075fec0ea30a7a1d88f6683ce370eb97 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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