Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ledPin = 4
ledValue = false
gpio.mode(ledPin, gpio.OUTPUT)
srv=net.createServer(net.TCP)
srv:listen(80,
function(conn)
conn:on("receive",
function(conn, payload)
ledValue = not ledValue
conn:send("<h1> LED: " .. (ledValue and "On" or "Off") .. "</h1>")
gpio.write(ledPin, ledValue and gpio.HIGH or gpio.LOW)
end)
conn:on("sent",function(conn) conn:close() end)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment