# Bibliotheken laden
from machine import Pin
from random import randint
# GPIOs für den Zähler auswählen
GPIO = [19, 18, 17, 16, 13, 14, 15]
leds = len(GPIO)
led = [0] * leds
# Würfel-Augen definieren
cube = ("0000000",
"1000000",
"0100001",
"1100001",
"0101101",
"1101101",
"0111111")
# Initialisierung von GPIOs
for i in range(leds):
led[i] = Pin(GPIO[i], Pin.OUT, value=0)
# Funktion
def wuerfeln():
# Zufall erzeugen
rand = randint(1, leds-1)
eye = cube[rand]
# LEDs aktivieren
print('Auge:', rand)
for i in range (leds):
if eye[i] == "1":
led[i].on()
else:
led[i].off()
wuerfeln()