ledR = 5 --GPIO14 ledG = 7 -- ledB = 6 function led(r,g,b) pwm.setduty(ledR,r) pwm.setduty(ledG,g) pwm.setduty(ledB,b) end wifi.setmode(wifi.STATION) wifi.sta.config("lightplot","lightplot") wifi.sta.setip({ip="192.168.42.2",netmask="255.255.255.0",gateway="192.168.42.1"}) gpio.mode(ledR, gpio.OUTPUT) gpio.mode(ledG, gpio.OUTPUT) gpio.mode(ledB, gpio.OUTPUT) pwm.setup(ledR,500,0) pwm.setup(ledG,500,0) pwm.setup(ledB,500,0) pwm.start(ledR) pwm.start(ledG) pwm.start(ledB) currentR = 0 currentG = 0 currentB = 0 led(currentR,currentG,currentB) -- red srv=net.createServer(net.TCP) srv:listen(80,function(conn) conn:on("receive", function(client,request) local buf = ""; local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP"); if(method == nil)then _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP"); end local _GET = {} if (vars ~= nil)then for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do _GET[k] = v if (k == "RED")then currentR = v end if (k == "GREEN")then currentG = v end if (k == "BLUE")then currentB = v end end end led(currentR,currentG,currentB); buf = buf..""; buf = buf.."

ESP8266 Web Server RGB LED

"; buf = buf.."
"; buf = buf.."

RED

"; buf = buf.."

GREEN

"; buf = buf.."

BLUE

"; buf = buf.."

"; buf = buf.."
"; buf = buf..""; client:send(buf); client:close(); collectgarbage(); end) end)