Skip to content

A Simple First Script

Marek Ziółkowski edited this page Jan 25, 2016 · 2 revisions

Toggle the on-board LED at a period of two seconds

Here's a simple first script for testing out your NodeMCU devkit, taken from Rui Santos' Getting Started with the ESPlorer:

lighton=0
pin=4
gpio.mode(pin,gpio.OUTPUT)
tmr.alarm(1,2000,1,function()
    if lighton==0 then
        lighton=1
        gpio.write(pin,gpio.HIGH)
    else
        lighton=0
         gpio.write(pin,gpio.LOW)
    end
end)
Clone this wiki locally