from machine import Pin
from neopixel import NeoPixel
from time import sleep_ms, sleep
matrix = NeoPixel(Pin(0), 256)
button = Pin(15, Pin.IN, Pin.PULL_DOWN)
COLOR = (140, 10, 0)
BLACK = (0, 0, 0)
old_state = button.value()
matrix.fill(COLOR)
matrix.write()
matrix_state = True
def toggle_matrix(btn):
print("fac... ceva cu matricea")
global matrix_state
matrix_state = not matrix_state
print(matrix_state)
button.irq(toggle_matrix, button.IRQ_FALLING)
"""
while True:
print("zzz")
sleep(2)
while True:
current_state = button.value()
# we are only interested in the button being pressed
if current_state and current_state != old_state:
print("will toggle matrix")
matrix_state = not matrix_state
if matrix_state:
matrix.fill(COLOR)
else:
matrix.fill(BLACK)
matrix.write()
old_state = current_state
sleep_ms(100)
"""