import random
from machine import Pin
import time 

led1 = Pin(4, Pin.OUT)
led2 = Pin(2, Pin.OUT)
led3 = Pin(15, Pin.OUT)
led4 = Pin(5, Pin.OUT)
led5 = Pin(19, Pin.OUT)
led6 = Pin(18, Pin.OUT)
led7 = Pin(21, Pin.OUT)
gumb = Pin(13, Pin.IN, Pin.PULL_UP)

def ena():
    led7.value(1)
    time.sleep(0.5)

def dva():
    led1.value(1)
    led6.value(1)
    time.sleep(0.5)

def tri():
    led1.value(1)
    led6.value(1)
    led7.value(1)
    time.sleep(0.5)

def stiri():
    led1.value(1)
    led3.value(1)
    led4.value(1)
    led6.value(1)
    time.sleep(0.5)

def pet():
    led1.value(1)
    led3.value(1)
    led4.value(1)
    led6.value(1)
    led7.value(1)
    time.sleep(0.5)

def sest():
    led1.value(1)
    led2.value(1)
    led3.value(1)
    led4.value(1)
    led5.value(1)
    led6.value(1)
    time.sleep(0.5)


while True:
    if gumb.value() == 0:
        for x in range(6):
            stev = random.randint(1,6)
            if stev == 1:
                ena()
                hi()
            elif stev == 2:
                dva()
                hi()
            elif stev == 3:
                tri()
                hi()
            elif stev == 4:
                stiri()
                hi()
            elif stev == 5:
                pet()
                hi()
            elif stev == 6:
                sest()
                hi()
        time.sleep(2)