from machine import Pin
import time
btn=Pin(3,Pin.IN, Pin.PULL_UP)
r=Pin(10,Pin.OUT)
g=Pin(11,Pin.OUT)
b=Pin(12,Pin.OUT)
COLORS=[
(1,0,0), #빨강
(0,1,0), #초록
(0,0,1), #파랑
(1,1,0), #노랑
(1,1,1), #흰색
(0,0,0), #꺼짐
]
index=0
def show(rgb):
r.value(rgb[0])
g.value(rgb[1])
b.value(rgb[2])
show(COLORS[index])
while True:
if btn.value()==0:
index=(index+1)%len(COLORS) #다음색, 끝나면 처음으로
show(COLORS[index])
print(index)
time.sleep(0.3)
time.sleep(0.02)