Created
February 6, 2025 19:32
-
-
Save TTZPlayz/b3b3251d30b0728067fa9d7245dda65c to your computer and use it in GitHub Desktop.
I was able to finish this in class, a continuation from the last gist.
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
# Write your code here :-) | |
import time | |
import board | |
import neopixel | |
pixel_pin = board.D2 #the ring data is connected to this pin | |
num_pixels = 4 #number of leds pixels on the ring | |
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.5, auto_write=False) | |
RED = (255, 0, 0) #RGB | |
YELLOW = (255, 150, 0) | |
GREEN = (0, 255, 0) | |
CYAN = (0, 255, 255) | |
BLUE = (0, 0, 255) | |
PURPLE = (180, 0, 255) | |
WHITE = (255, 255, 255) | |
OFF = (0, 0, 0) | |
myCOLORS = [RED, YELLOW, GREEN, CYAN, BLUE, PURPLE, WHITE, OFF] | |
while True: | |
for color_index in range(0, len(myCOLORS), 1): | |
pixels[0] = myCOLORS[color_index] | |
pixels.show() | |
color_index = color_index + 1 | |
if (color_index >= 7): | |
color_index = 0 | |
pixels[1] = myCOLORS[color_index] | |
pixels.show() | |
color_index = color_index + 1 | |
if (color_index >= 7): | |
color_index = 0 | |
pixels[2] = myCOLORS[color_index] | |
pixels.show() | |
color_index = color_index + 1 | |
if (color_index >= 7): | |
color_index = 0 | |
pixels[3] = myCOLORS[color_index] | |
pixels.show() | |
time.sleep(0.1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment