from machine import Pin
from time import sleep
c1=Pin(4,Pin.OUT)
c2=Pin(5,Pin.OUT)
c3=Pin(10,Pin.OUT)
c4=Pin(1,Pin.OUT)
c5=Pin(2,Pin.OUT)
c6=Pin(0,Pin.OUT)
c7=Pin(3,Pin.OUT)
c = [c1, c2, c3, c4, c5, c6, c7]
s1=Pin(6,Pin.OUT)
s2=Pin(7,Pin.OUT)
s3=Pin(8,Pin.OUT)
s4=Pin(9,Pin.OUT)
s5=Pin(13,Pin.OUT)
s6=Pin(12,Pin.OUT)
s7=Pin(11,Pin.OUT)
s = [s1, s2, s3, s4, s5, s6, s7]
button1=Pin(14,Pin.IN,Pin.PULL_DOWN)
button2=Pin(15,Pin.IN,Pin.PULL_DOWN)
button3=Pin(27,Pin.IN,Pin.PULL_DOWN)
button4=Pin(17,Pin.IN,Pin.PULL_DOWN)
button5=Pin(18,Pin.IN,Pin.PULL_DOWN)
blue=Pin(19,Pin.OUT)
red=Pin(26,Pin.OUT)
yellow=Pin(28,Pin.OUT)
running = False
running2 = False
running3 = False
running4 = False
all_on = False
rgb_state = 0
mix = [s1, s2, s3, c1, c2, c6, c7]
mix4 = [s4, s5, s6, s7, c3, c4, c5]
while True:
if button1.value():
running = not running
sleep(0.3)
if button2.value():
running2 = not running2
sleep(0.3)
if button3.value():
running3 = not running3
sleep(0.3)
if button4.value():
running4 = not running4
sleep(0.3)
if button5.value():
all_on = not all_on
running = False
running2 = False
running3 = False
running4 = False
sleep(0.3)
# ===== RGB =====
if rgb_state == 0:
red.value(1); blue.value(0); yellow.value(0)
elif rgb_state == 1:
red.value(0); blue.value(1); yellow.value(0)
elif rgb_state == 2:
red.value(0); blue.value(0); yellow.value(1)
rgb_state = (rgb_state + 1) % 3
sleep(0.3)
if running:
for led in c:
if not running:
break
led.value(1)
print("alaa")
sleep(0.2)
for led in c:
led.value(0)
sleep(0.2)
else:
for led in c:
led.value(0)
if running2:
for led in s:
if not running2:
break
led.value(1)
print("ali")
sleep(0.2)
for led in s:
led.value(0)
sleep(0.2)
else:
for led in s:
led.value(0)
if running3:
for led in mix:
if not running3:
break
led.value(1)
sleep(0.2)
for led in mix:
led.value(0)
sleep(0.2)
else:
for led in mix:
led.value(0)
if running4:
for led in mix4:
if not running4:
break
led.value(1)
sleep(0.2)
for led in mix4:
led.value(0)
sleep(0.2)
else:
for led in mix4:
led.value(0)
if all_on:
for led in c:
led.value(1)
for led in s:
led.value(1)
else:
for led in c:
led.value(0)
for led in s:
led.value(0)