from machine import Pin
from neopixel import NeoPixel
from time import sleep
def np_handler(ring, color, number, time1, time2):
for i in range(number):
ring[i] = color
ring.write()
sleep(time1)
sleep(time2)
def hanukkia_handler(shamash, candles, day):
fire = [255, 180, 100]
off = [0, 0, 0]
np_handler(shamash, fire, 8, 0.01, 1) # turn shamash on
np_handler(candles, fire, day, 1, 3) # turn hanukkia on for 3 seconds
np_handler(shamash, off, 8, 0.01, 0.01) # turn shamash off
np_handler(candles, off, day, 0.01, 3) # turn hanukkia off for 3 seconds
helper_pin = Pin(13, Pin.OUT)
hanukkia_pin = Pin(14, Pin.OUT)
helper = NeoPixel(helper_pin, 8)
hanukkia = NeoPixel(hanukkia_pin, 12)
while True:
for each_day in range(8):
hanukkia_handler(helper, hanukkia, each_day+1 )