Kết nối phần cứng Viết code # Example using PWM to fade an LED. import utime, _thread from machine import Pin, PWM led_red = PWM(Pin(14)) pwm_red_width = 65536 pwm_red_dir = True led_green = PWM(Pin(13)) pwm_green_width = 65536 pwm_green_dir = True led_yellow = PWM(Pin(12)) pwm_yellow_width = 65536 pwm_yellow_dir = True led_red.freq(50) led_green.freq(50) led_yellow.freq(50) is_change = True button = Pin(17, Pin.IN) last_time_stamp = utime.ticks_us() def button_callback(pin): global is_change, last_time_stamp if utime.ticks_us() - last_time_stamp > 300000: last_time_stamp = utime.ticks_us() is_change = not is_change _thread.start_new_thread(task, (50, 0.05)) button.irq(trigger = Pin.IRQ_FALLING, handler = button_callback) led_25 = PWM(Pin(25)) led_25.freq(50) def task(n, delay): global led_25 for duty in range(0, 65536, +80): led_25.duty_u16(duty) utime.sleep(0.001) for duty in range(65536, 0, -80): led_25.d...