Created
August 23, 2015 12:14
-
-
Save tnoborio/792fd5b63074fb12e80a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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