from machine import Pin
import time
swr = Pin(2, Pin.IN)
swb = Pin(12, Pin.IN)
a = Pin(26, Pin.OUT)
b = Pin(22, Pin.OUT)
c = Pin(19, Pin.OUT)
d = Pin(20, Pin.OUT)
e = Pin(21, Pin.OUT)
f = Pin(27, Pin.OUT)
g = Pin(28, Pin.OUT)
count = 0
def zero():
a.on()
b.on()
c.on()
d.on()
e.on()
f.on()
g.off()
def one():
a.value(0)
b.value(1)
c.value(1)
d.value(0)
e.value(0)
f.value(0)
g.value(0)
def two():
a.value(1)
b.value(1)
c.value(0)
d.value(1)
e.value(1)
f.value(0)
g.value(1)
def three():
a.value(1)
b.value(1)
c.value(1)
d.value(1)
e.value(0)
f.value(0)
g.value(1)
def four():
a.value(0)
b.value(1)
c.value(1)
d.value(0)
e.value(0)
f.value(1)
g.value(1)
while True:
swr_val = swr.value()
print('Red Switch', swr_val)
time.sleep_ms(300)
swb_val = swb.value()
print('Blue Switch', swb_val)
time.sleep_ms(300)
if swr_val == 0:
count += 1
if count > 4:
count = 0
elif swb_val == 0:
count -= 1
if count < 0:
count = 4
if count == 0:
zero()
elif count == 1:
one()
elif count == 2:
two()
elif count == 3:
three()
elif count == 4:
four()