from machine import Pin, PWM
import time
led1 = Pin(16, Pin.OUT)
led2 = Pin(17, Pin.OUT)
led3 = Pin(18, Pin.OUT)
led4 = Pin(19, Pin.OUT)
led = [led1, led2, led3, led4]
i=0
duty=0
pot = ADC(Pin(12))
pot.atten(ADC.ATTN_11DB)
pot.width(ADC.WIDTH_12BIT)
def map(x, in_min, in_max, out_min, out_max):
return int((x - in_min)*(out_max - out_min)/(in_max - in_min)+ out_min)
while 1:
delay = map(pot.read(), 0, 4095, 0, 1000)
time.sleep_ms(50)
for i in range(0,4):
led[i].on()
time.sleep_ms(200)
led[i].off()
time.sleep_ms(200)
for i in range(2,0,-1):
led[i].on()
time.sleep_ms(200)
led[i].off()
time.sleep_ms(200)
'''
duty+=25
if duty>1023:
duty=0
time.sleep_ms(200)
'''