from micropyserver import MicroPyServer import time from machine import Pin, PWM import network import gc _init() gc.collect() LedR = PWM(Pin(13, Pin.OUT)) LedG = PWM(Pin(14, Pin.OUT)) LedB = PWM(Pin(15, Pin.OUT)) wlan_id = "Wi-Fi_Name" wlan_pass = "Wi-Fi_Password" wlan = network.WLAN(network.STA_IF) wlan.active(True) wlan.connect(wlan_id, wlan_pass) time.sleep(1) while wlan.isconnected() == False: pass print('Device IP:', wlan.ifconfig()[0]) def index(request, params): duty_r = '512' duty_g = '512' duty_b = '512' if ('r' in params): duty_r = params['r'] LedR.duty(1023 - int(duty_r)) if ('g' in params): duty_g = params['g'] LedG.duty(1023 - int(duty_g)) if ('b' in params): duty_b = params['b'] LedB.duty(1023 - int(duty_b)) html_file = open("rgb_page.html") html = html_file.read() html = html.replace('<=VALUE=R=>', duty_r) html = html.replace('<=VALUE=G=>', duty_g) html = html.replace('<=VALUE=B=>', duty_b) html_file.close() server.send(html, content_type="Content-Type: text/html") LedR.duty(0) LedG.duty(0) LedB.duty(0) server = MicroPyServer() server.add_route("/", index) server.start()