-- Originally created by Rui Santos -- Modified by Derek Belz to work with the latest NodeMCU firmware -- Complete project details at http://randomnerdtutorials.com wifi.setmode(wifi.STATION) wifi.sta.config({ssid="YOUR_NETWORK_NAME",pwd="YOUR_NETWORK_PASSWORD"}) print(wifi.sta.getip()) function led(r, g, b) pwm.setduty(5, r) pwm.setduty(6, g) pwm.setduty(7, b) end pwm.setup(5, 1000, 1023) pwm.setup(6, 1000, 1023) pwm.setup(7, 1000, 1023) pwm.start(5) pwm.start(6) pwm.start(7) if srv ~= nil then -- prevents "out of memory". Prompts connected, but you can ignore it srv:close() end srv=net.createServer(net.TCP) srv:listen(80,function(conn) conn:on("receive", function(client,request) local buf = ""; buf = buf.."HTTP/1.1 200 OK\n\n" 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 end end buf = buf..""; buf = buf..""; buf = buf..""; buf = buf..""; buf = buf..""; buf = buf..""; buf = buf..""; buf = buf.."

ESP Color Picker

"; buf = buf.."Change Color "; buf = buf.."
"; buf = buf..""; if(_GET.r or _GET.g or _GET.b) then -- This is for RGB Common Cathode led(_GET.r, _GET.g,_GET.b) -- This is for RGB Common Anode -- led(1023-_GET.r, 1023-_GET.g,1023-_GET.b) end client:send(buf) conn:on("sent", function(c) c:close() end) end) end)