Skip to content

Instantly share code, notes, and snippets.

@isevcik
Created December 10, 2017 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isevcik/fcdf7dbe6013a6d9f2f49552dbaefcf3 to your computer and use it in GitHub Desktop.
Save isevcik/fcdf7dbe6013a6d9f2f49552dbaefcf3 to your computer and use it in GitHub Desktop.
esp8266 nodeMCU script
return function (connection, req, args)
dofile('httpserver-header.lc')(connection, 200, 'html')
led1 = {}
led1.pin = 0
led1.value = gpio.LOW;
led2 = {}
led2.pin = 4
led2.value = gpio.HIGH
gpio.mode(led1.pin, gpio.OUTPUT)
gpio.mode(led2.pin, gpio.OUTPUT)
tmr.create():alarm(1000, tmr.ALARM_AUTO, function()
toggle(led1)
toggle(led2)
end)
function toggle(led)
if led.value == gpio.LOW then led.value = gpio.HIGH else led.value = gpio.LOW end
gpio.write(led.pin, led.value)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment