from machine import Pin
from time import sleep
import laboratory2, laboratory3, laboratory4, laboratory5, laboratory6, laboratory7, laboratory8, laboratory9, laboratory10
lab2 = Pin(2, Pin.IN, Pin.PULL_UP)
lab3 = Pin(3, Pin.IN, Pin.PULL_UP)
lab4 = Pin(4, Pin.IN, Pin.PULL_UP)
lab5 = Pin(5, Pin.IN, Pin.PULL_UP)
lab6 = Pin(6, Pin.IN, Pin.PULL_UP)
lab7 = Pin(7, Pin.IN, Pin.PULL_UP)
lab8 = Pin(8, Pin.IN, Pin.PULL_UP)
lab9 = Pin(9, Pin.IN, Pin.PULL_UP)
lab10 = Pin(10, Pin.IN, Pin.PULL_UP)
def main():
while True:
switch1_state = lab2.value()
switch2_state = lab3.value()
switch3_state = lab4.value()
switch4_state = lab5.value()
switch5_state = lab6.value()
switch6_state = lab7.value()
switch7_state = lab8.value()
switch8_state = lab9.value()
switch9_state = lab10.value()
#count the number of switches ON
switch_count = switch1_state + switch2_state + switch3_state + switch4_state + switch5_state + switch6_state + switch7_state + switch8_state + switch9_state
#if 2 or more switches are ON, no pattern will execute to the LEDS
if switch_count >= 2 or switch_count == 0:
print(str(switch_count)+" switches are pressed.")
else:
if lab2.value() == 1:
laboratory2.main()
if lab3.value() == 1:
laboratory3.main()
if lab4.value() == 1:
laboratory4.main()
if lab5.value() == 1:
laboratory5.main()
if lab6.value() == 1:
laboratory6.main()
if lab7.value() == 1:
laboratory7.main()
if lab8.value() == 1:
laboratory8.main()
if lab9.value() == 1:
laboratory9.main()
if lab10.value() == 1:
laboratory10.main()
if __name__ == '__main__':
main()