esp8266 Relay-IO by classdisk

Cloned from Sketch esp8266 Relay-IO by komfile

This sketch is missing a short description
http://www.esp8266.com/blog/index.php/2015/09/07/esp8266-solid-state-relay-controller-project-idea/ Basic Code: cls Print “ESP8266 WiFi Solid State Relay” print Button “On” [on] button “Off” [off] button “Exit” [exit] wait [on] po 2 0 Wait [off] po 2 1 wait ================================================================================================== Lua Code: -------------------------------------------------------------------------------------------------- wifi.setmode(wifi.STATION); wifi.ap.config({ssid="YOURNETWORKHERE",pwd="YOURPASSWORDHERE"}); pin = 4; gpio.mode(pin, gpio.OUTPUT) 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 end end buf = buf.."<h1> Hello, NodeMcu.</h1><form src=\"/\">Turn PIN <select name=\"pin\" onchange=\"form.submit()\">"; local _on,_off = "","" if(_GET.pin == "ON")then _on = " selected=true"; gpio.write(pin, gpio.HIGH); elseif(_GET.pin == "OFF")then _off = " selected=\"true\""; gpio.write(pin, gpio.LOW); end buf = buf.."<option".._on..">ON</opton><option".._off..">OFF</option></select></form>"; client:send(buf); client:close(); collectgarbage(); end) end)

Embed This Sketch

Use the following HTML code to embed the sketch code above in your blog or website.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/sketch:518753" frameborder="0"></iframe>

Embed The Serial Monitor

You can also embed the Serial Monitor section! Just use this HTML code.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/serialmonitor" frameborder="0"></iframe>