from machine import Pin, PWM
import time
taster1 = Pin(32, Pin.IN, Pin.PULL_DOWN)
taster2 = Pin(33, Pin.IN, Pin.PULL_DOWN)
led1 = Pin(18, Pin.OUT)
pwm_led2 = PWM(Pin(19))
pwm_led2.freq(5000)
duty_cycle = 0
direction = 1
while True:
if taster1.value() == 1:
led1.on()
print("LED 1 ein")
else:
led1.off()
if taster2.value() == 1:
duty_cycle += direction * 5
if duty_cycle >= 1023:
duty_cycle = 1023
direction = -1
elif duty_cycle <= 0:
duty_cycle = 0
direction = 1
pwm_led2.duty(duty_cycle)
print("LED 2 puls")
else:
pwm_led2.duty(0)