# https://docs.micropython.org/en/latest/esp8266/tutorial/pwm.html # On the ESP8266 the pins 0, 2, 4, 5, 12, 13, 14 and 15 all support PWM. # The limitation is that they must all be at the same frequency, # and the frequency must be between 1Hz and 1kHz. from machine import Pin, PWM from time import sleep red = Pin(12) pwm_red = PWM(red) freq = 1 pwm_red.freq(freq) pwm_red.duty(1) # maximaler Wert 1023 print(pwm_red.duty(), pwm_red.freq()) # pwm_redt() sleep(10*freq) duty_cycle = 1 freq = 10 pwm_red.freq(freq) while True: print("a:") for i in range(1,1023+64,64): pwm_red.duty(i) print(i, end=" ") sleep(1) print("b:") for i in range(1023,-1,-64): pwm_red.duty(i) print(i,end=" ") sleep(0.5)