from machine import Pin
import time
led_red = Pin(15, Pin.OUT)
led_orange = Pin(13, Pin.OUT)
led_yelow = Pin(11, Pin.OUT)
led_green = Pin(9, Pin.OUT)
led_blue = Pin(6, Pin.OUT)
led_darkblue = Pin(4, Pin.OUT)
led_purple = Pin(2, Pin.OUT)
btn_red = Pin(16, Pin.IN)
btn_grey = Pin(17, Pin.IN)
btn_yellow = Pin(18, Pin.IN)
btn_green = Pin(19, Pin.IN)
btn_white = Pin(20, Pin.IN)
btn_darkblue = Pin(21, Pin.IN)
btn_black = Pin(22, Pin.IN)
while 1:
logic_state_red = btn_red.value()
if logic_state_red == True:
print('красная кнопка нажата')
led_red.toggle()
print('красный диод включен')
logic_state_grey = btn_grey.value()
if logic_state_grey == True:
print('серая кнопка нажата')
led_orange.toggle()
print('оранжевый диод включен')
logic_state_yellow = btn_yellow.value()
if logic_state_yellow == True:
print('желтая кнопка нажата')
led_yelow.toggle()
print('желтый диод включен')
logic_state_green = btn_green.value()
if logic_state_green == True:
print('зеленая кнопка нажата')
led_green.toggle()
print('зеленый диод включен')
logic_state_white = btn_white.value()
if logic_state_white == True:
print('белая кнопка нажата')
led_blue.toggle()
print('голубой диод включен')
logic_state_darkblue = btn_darkblue.value()
if logic_state_darkblue == True:
print('синяя кнопка нажата')
led_darkblue.toggle()
print('синий диод включен')
logic_state_black = btn_black.value()
if logic_state_black == True:
print('черная кнопка нажата')
led_purple.toggle()
print('фиолетовый диод включен')
# number = input()
# for color in colors:
# if color == 'red':
# led_red.on()
# led_green.off()
# led_blue.off()
# print('RED is ON')
# if color == 'green':
# led_green.on()
# led_red.off()
# led_blue.off()
# print('GREEN is ON')
# if color == 'blue':
# led_blue.on()
# led_green.off()
# led_red.off()
# print('BLUE is ON')
# if color == 'all':
# led_blue.on()
# led_green.on()
# led_red.on()
# print('ALL ARE ON')
# time.sleep(1)