Categories

Follow

Blink an LED with NodeMCU

In this example we simple flash an LED connected to a nodemcu (esp8266) board. We will use lua for this example.

You will need a NodeMCU board, an led and a resistor, some connecting wire and if you are using components a breadboard makes life easier, I use combined LEDs and resistors on small modules which greatly simplify things removing the need of the breadboard

 

Layout

The layout assumes the use of a breadboard, I have chosen a 470 ohms resistor

nodemcu and led

nodemcu and led

 

Code

Save this as ledflash.lua and load it via the ESPlorer, video underneath shows this

LED_PIN = 1
 
gpio.mode(LED_PIN, gpio.OUTPUT)
value = true
 
tmr.alarm(0, 500, 1, function ()
    gpio.write(LED_PIN, value and gpio.HIGH or gpio.LOW)
    value = not value
end)

 

Video

The video shows me using the ESPlorer tool to connect to the NodeMCU board, open my lua file and then upload to my NodeMCU board

 

 

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

*