Skip to content

Instantly share code, notes, and snippets.

@tnoborio
Created August 23, 2015 12:14
Show Gist options
  • Save tnoborio/792fd5b63074fb12e80a to your computer and use it in GitHub Desktop.
Save tnoborio/792fd5b63074fb12e80a to your computer and use it in GitHub Desktop.
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