LED Blink with ESP8266 NodeMCU

LED Blink with ESP8266 NodeMCU

Share it

ESP8266 NodeMCU is the smallest & cheapest IoT Development board. Price is only starting from $2. There are two chipset models available, one is CH340 and another one is CP2102. You can buy it from the following links.

Buy Link

CH340 AliExpress Amazon
CP2102 AliExpress Amazon

Every new user of the IoT development board starts with the LED blinking code.  This led blinking code is not very difficult to understand for a new user.  This simple LED blinking project will make a user familiar with all the input and output pins of ESP 8266. 

In this post, I will share the code for LED blinking.  But before that, I will quickly introduce you to all the segments of Arduino IDE.

If you do not know how to set up ESP 8266 with Arduino IDE then follow these post.

How to Upload code in ESP8266 Nodemcu from Arduino IDE

ESP8266 Nodemcu Pins Constant Integer values for coding

Components Used:

Here in this tutorial, we will set D7 pin as the digital output pin. We will connect LED positive(+) leg to D7 via 220-ohm resistor. The resistor is not mandatory, but it is good for safety. At last, we will connect the LED negative(-) leg to Ground of NodeMCU.

Code Explain

Within the void setup area, we have set the pin D7 as the digital output pin.
Inside the Void Loop whatever we write it will repeat infinitely.

We will use the delay function of 2 seconds to make LED on & off for 2 seconds repeatedly. Delay function accepts a parameter of milliseconds. So we have given value as 2000.

Using serial print we will just print led on / off in the serial monitor. This is not mandatory.

Before void Setup area we can add header files and initialize constants and variables.

Arduino Sketch


You can also watch this tutorial video in Hindi.

Watch Video Tutorial

Share it

Leave Comment