Created
December 10, 2017 15:57
-
-
Save isevcik/fcdf7dbe6013a6d9f2f49552dbaefcf3 to your computer and use it in GitHub Desktop.
esp8266 nodeMCU script
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
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