from machine import Pin
import utime
PORT = [7,6,5,4,3,2,1,0]
DIR = ['0','0','0','0','0','0','0','0']
L = [0]*8
def Configure_Port():
for i in range(0, 8):
if DIR[i] == '0':
L[i] = Pin(PORT[i], Pin.OUT)
print (L[i], end=' ')
else:
L[i] = Pin(PORT[i], Pin.IN)
return
def Port_Output(x):
b = bin(x)
b = b.replace('0b', '')
diff = 8 - len(b)
for i in range (0, diff):
b = '0' + b
for i in range (0, 8):
if b[i] == '1':
L[i].value(1)
else:
L[i].value(0)
return
Configure_Port()
cnt = 0
while True:
Port_Output(cnt)
utime.sleep(0.3)
cnt = cnt + 1
if cnt > 255:
cnt = 0