Created
May 5, 2025 18:16
-
-
Save adilk28/f8d8b0cac2f0297a999221c16d5491c6 to your computer and use it in GitHub Desktop.
Nesting two loops - red in all lights
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 time | |
import board | |
import neopixel | |
pixel_pin = board.D2 | |
num_pixels = 16 | |
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.7, auto_write=False) | |
while True: | |
for red_fade_value in range(0, 254, 2): #fade in loop | |
color = (red_fade_value, 255, 25) | |
for light_index in range (0, 16, 1): | |
pixels[light_index] = color | |
pixels.show() | |
for red_fade_value in range(254d, 0, -2): #fade out loop | |
color = (red_fade_value, 25, 255) | |
for light_index in range(0, 16, 1): | |
pixels[light_index] = color | |
pixels.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment