from machine import Pin, ADC, PWM
from utime import sleep
ledS1 = Pin(10,Pin.OUT)
ledS2 = Pin(11,Pin.OUT)
ledS3 = Pin(12,Pin.OUT)
ledS4 = Pin(13,Pin.OUT)
ledB = Pin(16,Pin.OUT)
led1 = Pin(2,Pin.OUT)
led2 = Pin(3,Pin.OUT)
led3 = Pin(4,Pin.OUT)
led4 = Pin(5,Pin.OUT)
led5 = Pin(6,Pin.OUT)
led6 = Pin(7,Pin.OUT)
led7 = Pin(8,Pin.OUT)
led8 = Pin(9,Pin.OUT)
an = ADC(Pin(28))
pb = Pin(20,Pin.IN,Pin.PULL_UP)
masa = 0.2
while True:
mode = int(an.read_u16() / 16383) + 1
print(mode)
sleep(0.1)
if mode==1:
ledS1.value(1)
ledS2.value(0)
ledS3.value(0)
ledS4.value(0)
if mode==2:
ledS1.value(0)
ledS2.value(1)
ledS3.value(0)
ledS4.value(0)
if mode==3:
ledS1.value(0)
ledS2.value(0)
ledS3.value(1)
ledS4.value(0)
if mode==4:
ledS1.value(0)
ledS2.value(0)
ledS3.value(0)
ledS4.value(1)
if pb.value()==0:
if mode==1: # running light
led1.value(1)
sleep(masa)
led1.value(0)
led2.value(1)
sleep(masa)
led2.value(0)
led3.value(1)
sleep(masa)
led3.value(0)
led4.value(1)
sleep(masa)
led4.value(0)
led5.value(1)
sleep(masa)
led5.value(0)
led6.value(1)
sleep(masa)
led6.value(0)
led7.value(1)
sleep(masa)
led7.value(0)
led8.value(1)
sleep(masa)
led8.value(0)
sleep(masa)
led8.value(1)
sleep(masa)
led8.value(0)
led7.value(1)
sleep(masa)
led7.value(0)
led6.value(1)
sleep(masa)
led6.value(0)
led5.value(1)
sleep(masa)
led5.value(0)
led4.value(1)
sleep(masa)
led4.value(0)
led3.value(1)
sleep(masa)
led3.value(0)
led2.value(1)
sleep(masa)
led2.value(0)
led1.value(1)
sleep(masa)
led1.value(0)
sleep(masa)
if mode==2: # knight rider
for i in range(2):
led1.value(1)
sleep(masa)
led2.value(1)
sleep(masa)
led3.value(1)
sleep(masa)
led4.value(1)
sleep(masa)
led1.value(0)
led5.value(1)
sleep(masa)
led2.value(0)
led6.value(1)
sleep(masa)
led3.value(0)
led7.value(1)
sleep(masa)
led4.value(0)
led8.value(1)
sleep(masa)
led5.value(0)
sleep(masa)
led6.value(0)
sleep(masa)
led7.value(0)
sleep(masa)
led8.value(0)
sleep(masa)
led8.value(1)
sleep(masa)
led7.value(1)
sleep(masa)
led6.value(1)
sleep(masa)
led5.value(1)
sleep(masa)
led4.value(1)
led8.value(0)
sleep(masa)
led3.value(1)
led7.value(0)
sleep(masa)
led2.value(1)
led6.value(0)
sleep(masa)
led1.value(1)
led5.value(0)
sleep(masa)
led4.value(0)
sleep(masa)
led3.value(0)
sleep(masa)
led2.value(0)
sleep(masa)
led1.value(0)
sleep(masa)
if mode==3: # blinking all
asd
asd
if mode==4: # fadeup, fadedown
asd
asd
else:
ledB.toggle()
sleep(0.5)