from machine import Pin
import random
import time
from time import sleep
led1 = Pin(18, Pin.OUT)
led2 = Pin(21, Pin.OUT)
led3 = Pin(19, Pin.OUT)
led4 = Pin(4, Pin.OUT)
led5 = Pin(5, Pin.OUT)
led6 = Pin(17, Pin.OUT)
led7 = Pin(16, Pin.OUT)
gumb = Pin(35, Pin.IN, Pin.PULL_UP)
def ena():
led3.value(1)
sleep(0.5)
def dva():
led1.value(1)
led6.value(1)
sleep(0.5)
def tri():
led1.value(1)
led6.value(1)
led3.value(1)
sleep(0.5)
def stir():
led1.value(1)
led5.value(1)
led4.value(1)
led6.value(1)
sleep(0.5)
def pet():
led1.value(1)
led5.value(1)
led4.value(1)
led6.value(1)
led3.value(1)
sleep(0.5)
def sest():
led1.value(1)
led5.value(1)
led4.value(1)
led6.value(1)
led2.value(1)
led7.value(1)
sleep(0.5)
def ugasn():
led1.value(0)
led2.value(0)
led3.value(0)
led4.value(0)
led5.value(0)
led6.value(0)
led7.value(0)
while True:
if gumb.value() == 1:
for _ in range(9):
met = random.randint(1, 6)
if met == 1:
ena()
elif met == 2:
dva()
elif met == 3:
tri()
elif met == 4:
stir()
elif met == 5:
pet()
elif met == 6:
sest()
ugasn()
met = random.randint(1, 6)
if met == 1:
ena()
elif met == 2:
dva()
elif met == 3:
tri()
elif met == 4:
stir()
elif met == 5:
pet()
elif met == 6:
sest()
print(met)
sleep(1.5)
ugasn()