from machine import ADC, Pin, PWM, Timer
import time
from time import sleep
button = Pin(14, Pin.IN, Pin.PULL_DOWN)
timer = Timer()
adc = ADC(Pin(26))
led = Pin(25, Pin.OUT)
pwm = PWM(Pin(12))
pwm.freq(1000)
Lpwm = PWM(Pin(15))
Lpwm.freq(1000)
def blink(timer):
led.toggle()
timer.init(freq=2.5, mode=Timer.PERIODIC, callback=blink)
while True:
print(adc.read_u16())
duty = adc.read_u16()
pwm.duty_u16(duty)
time.sleep(1)
if button.value():
led.toggle()
time.sleep(0.5)
for duty in range(65025):
Lpwm.duty_u16(duty)
sleep(0.0001)
for duty in range(65025, 0, -1):
Lpwm.duty_u16(duty)
sleep(0.0001)