Lolin NodeMCU IO Basics: Blink

Arduino IDE Blink Program for ESP8266 NodeMCU 12-E

Before diving into IoT, it is necessary to learn how to deal with inputs and outputs to your Lolin NodeMCU.    This tutorial will show you how to make 5mm LED blink using your NodeMCU.   Using the Arduino IDE, you set the mode for one the NodeMCU pins and you will blink an LED at a 1 second rate.

If you haven’t already done so,  you will need to prepare your NodeMCU and your Arduino IDE.

This article shows you how:  Getting Started with the Lolin NodeMCU with the Arduino IDE

Because there are several ways to power your NodeMCU,  you may wish to to read about it HERE.

Getting the Stuff You Need

You will need a NodeMCU Module. The module can be found from any of the following vendors:

Amazon     eBay     Bang Good   Deal Extreme

You will need a micro USB Cable.


Arduino IDE Digital IO Pin Mapping

The IO Pin markings on the NodeMCU development board are D0 through D8.   These DO NOT correspond to the IO Pin numbers you need to use while programming.  Instead the numbers you need to use are those of the ESP8266 chip that these are connected to.  These numbers are shown in the illustration below.

Other pins are also available.  RX and TX in fact map to 3 and 1 for example.  However they can be trickier to use. Pins D0 through to D8 are generally enough for most projects.

NOTE If you choose to use D4,  disconnect the LED while programming.  Pin 4 is often connected to a little blue LED on the ESP-12E circuit board.  This pin is used during programming and it will cause your upload to crash.

Connect the Components to your NodeMCU

Connect your components as shown in the drawing below.

The 150 Ohm resistor is to limit the current.  A typical 5mm LED will pull 20 mA and the GPIO outputs from your ESP8266 are only rated for 12mA.

I use a Minghe B3603 for a power supply in my installations.  As indicated earlier,  you can use another.

Copy, Paste and Upload the NodeMCU Blink Code

The code below is pretty straight forward.

Your LED will begin blinking immediately after your upload is complete.

int LedPin = 16;

void setup() { 
  pinMode(LedPin, OUTPUT);

void loop() {
  digitalWrite(LedPin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(LedPin, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second