from machine import Pin
import utime
import random
PORT = [i for i in range(1, 8)] # соединения порта
DIR = ["0" for i in range(7)] # направления порта
L = [0] * 7
button = Pin(15, Pin.IN)
print(PORT, DIR, L, sep='\n')
def Configure_pin():
for i in range(7):
if DIR[i] == "0":
L[i] = Pin(PORT[i], Pin.OUT)
print("Pin number", L, sep='\n')
def port_output(x):
b = bin(x)
b = b.replace("0b", "")
diff = 7 - len(b)
for i in range(0, diff):
b = "0" + b
print("This is binary number : ", b)
for i in range(7):
if b[i] == "1":
L[i].value(1)
else:
L[i].value(0)
return
Configure_pin()
print("Press the Button to display your luck number ")
#random.seed(utime.ticks_ms())
while True:
# ခလုတ် နှိပ်သည် အထိ စောင့် ရန် အတွက်
while button.value() == 1:
#pass
continue
r = random.randint(1, 7)
print("random number : ", r)
r = pow(2, r-1)
port_output(r)
utime.sleep(3)
print("END PROGRAM!!")