Created
June 16, 2025 18:54
-
-
Save sjenning/29f817feaee1f7b1eac98097be4a92be to your computer and use it in GitHub Desktop.
Cozy Minecraft Lantern Candle
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 random | |
import time | |
from array import * | |
pin = board.D4 | |
pixel_count = 9 | |
color_variance = 200 | |
rate = 10 | |
green_offset=50 | |
pixels = neopixel.NeoPixel(pin, pixel_count, brightness=1, auto_write=False) | |
green = random.randint(0, color_variance)+green_offset | |
current_green = 0 | |
while True: | |
if abs(current_green - green) < rate: | |
green = random.randint(0, color_variance)+green_offset | |
if current_green < green: | |
current_green += rate | |
else: | |
current_green -= rate | |
for p in range(pixel_count): | |
pixels[p] = (255, current_green, 0) | |
pixels.write() | |
time.sleep(0.05) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment