<aside> 📎 This is the solution to the challenge within GPIO and Machine Library
</aside>
import machine
import neopixel
import time
from lib.brain.display import *
matrix = Matrix()
ring = neopixel.NeoPixel(machine.Pin(13), 12)
right_button = machine.Pin(0, machine.Pin.IN)
current_index = 0
cur_time = time.ticks_ms()
while True:
ring[current_index] = (200, 0, 200)
ring[(current_index - 1) % 12] = (0, 0, 0)
ring[6] = (0, 200, 200)
ring.write()
if current_index == 6 and right_button.value() == 0:
matrix.scroll("WIN", red=0, green=200, blue=0, speed=0.1)
elif current_index != 6 and right_button.value() == 0:
matrix.scroll("LOSE", red=200, green=0, blue=0, speed=0.1)
if time.ticks_ms() - cur_time > 200:
current_index = (current_index + 1) % 12
cur_time = time.ticks_ms()
time.sleep(0.01)