Blink external LED using ESP8266 NodeMCU (2024)

Previous Tutorial: Blinking BuiltIN_LED on ESP8266 NodeMCU.

In this tutorial, we will learn how to blink an external LED connected to NodeMCU.

Software Required:

Arduino IDE (Check installation here)

Hardware Required:

  1. Breadboard
  2. ESP8266 NodeMCU Lua Wifi
  3. LED
  4. Jumper (if needed)
  5. Micro USB

Blink external LED using ESP8266 NodeMCU (1)

Step 1) Connect LED’s anode to ESP8266’s GND pin and LED’s cathode to ESP8266 D1.

Step 2) Download the sample code from my Github.

Step 3) Compile the code in Arduino IDEand then upload it into ESP8266 NodeMCU using the micro USB cable.

Once the code is uploaded to the device, the external led Start’s blinking.

I have included the code for blinking both internal and external LED.You could just do the external LED by commenting out the below code forBUILTIN_LED

//pinMode(BUILTIN_LED, OUTPUT)

//digitalWrite(BUILTIN_LED, LOW);

//digitalWrite(BUILTIN_LED, HIGH);

Program Working

void setup() {} – setups the functionality of the pins

void loop() – Loops through the contents

pinMode(BUILTIN_LED, OUTPUT); – sets theBUILTIN_LED as output

pinMode(5, OUTPUT); – sets the LED as output

digitalWrite(BUILTIN_LED, LOW); Turn the LED on (Note that LOW is the voltage levelbut actually the LED is on; this is becauseit is active low on the ESP-01)

digitalWrite(BUILTIN_LED, HIGH);Turn the LED OFF

digitalWrite(5, LOW); – Turn on the LED

digitalWrite(5, HIGH); -Turn’s off the LED

delay(1000); – gives a delay of one second

Next Tutorial: DHT11 to record Temperature and Humidity on ESP8266 NodeMCU

Blink external LED using ESP8266 NodeMCU (2024)

FAQs

Blink external LED using ESP8266 NodeMCU? ›

Step 1) Connect LED's anode to ESP8266's GND pin and LED's cathode to ESP8266 D1. Step 2) Download the sample code from my Github. Step 3) Compile the code in Arduino IDE and then upload it into ESP8266 NodeMCU using the micro USB cable. Once the code is uploaded to the device, the external led Start's blinking.

How to connect NodeMCU ESP8266 to LED? ›

esp8266 led Circuit Diagram

Attach the digital-1 pin of the nodemcu with the one side pin of the pushbutton. Take an LED and place it on the breadboard. Join the positive leg of the LED with the digital-5 pin of the nodemcu. Connect the GND pin of the nodemcu with the negative leg of the LED via a 220-ohm resistor.

Can ESP8266 drive LED? ›

Introduction: The ESP8266 Part 3 - Triggering Arduino LEDs Remotely. After a long and dark winter, we come to drive LEDs (or anything) remotely via WiFi. By the way, someone once said "If you can blink a LED you can do anything." So, the importance of this 3rd and last tutorial about the ESP8266.

What is the pin code for NodeMCU built in LED? ›

First,connect the NodeMCU to the PC,put below code to the Arduino IDE: #define LED D0 // Led in NodeMCU at pin GPIO16 (D0).

How many LEDs can ESP8266 handle? ›

ESP8266. There is a maximum of 3 strips supported. It is highly recommended to use two specific LED pins, GPIO1 (TX) and GPIO2 (D4), since they allow for hardware driving. 800 LEDs/pin for a total of 1600 has been confirmed working, but is not recommended for good performance and reliability.

How do you manually flash ESP8266? ›

  1. Step 1: Firmware Flashing Breadboard. Setup your breadboard as per the above. ...
  2. Step 2: Schematic. ...
  3. Step 3: Get the Firmware Flasher Software. ...
  4. Step 6: Set the COM Port. ...
  5. Step 7: Set the ESP8266 Options. ...
  6. Step 8: Change the Firmware File. ...
  7. Step 9: Select the New Firmware File. ...
  8. Step 10: Start the Upload to the ESP8266.

Can I use ESP8266 without Arduino? ›

A few weeks ago I've created a project with an ESP8266 called: ESP8266 Web Server without an Arduino. That's exactly what you're going to build, if you follow all the steps in this Instructable. It's amazing what you can do with this $4 WiFi Module. The video below shows the final result of this project.

How to connect RGB LED to ESP8266? ›

If you are working with an RGB LED then connect the negative leg with the GND pin of the nodemcu via a 220-ohm resistor. Attach the rest of the pins (for green, blue, and red colors) with the digital pins of the nodemcu as shown above in the circuit diagram for esp8266 tutorial.

How do you blink LED with ESP32? ›

Connect the negative pin (cathode) of the LED, indicated as the flat edge of the LED to ground, shown as the blue wire. Connect the positive pin (anode) of the LED, indicated as the rounded edge of the LED to a 100Ω resistor. Connect the free end of the resistor to pin D5 on the ESP32, shown as the red wire.

What is the difference between Arduino and NodeMCU pin? ›

In both the microcontroller boards, these pins perform the same task. But the operating voltages for both the microcontroller are different. The digital pins of the Arduino UNO work in both 3.3V and 5V. But the digital pins of NodeMCU work only on 3.3V, more than that the microcontroller gets damaged.

Which pin is the on board LED of the ESP8266 connected? ›

Esp8266 Led turn on pin d4.

How long can ESP8266 run continuously? ›

Typical current consumption of an ESP8266 module in normal operation mode is 70mA. So, if we run an ESP module continuously in normal mode it will run only for one and a half day. But, most of the IoT device doesn't require transmitting data continuously.

How far can ESP8266 transmit? ›

Connecting to the WiFi module through a TPLink WR841N router, [CN] as able to ping the module at 479 meters with a huge rubber duck antenna soldered on, or 366 meters with the PCB antenna.

Can ESP8266 run 24 7? ›

The ESP8266 (NodeMCU) has a radio and a processor with running code. An NRF24 is just a radio, no MCU. My ESP modules are running without problems 24/7. It all has to do with a clean supply, proper code and non-interfering peripherals.

How to connect 16x2 LCD to NodeMCU? ›

Attach the Pins of the I2C module with the 16×2 LCD. Connect the VIN or 3.3-volts pin of the NodeMCU with the VCC pin of the I2C module and the GND pin of the NodeMCU with the GND pin of the I2C module. Join the SDA pin of the I2C module with the digital-2 pin of the NodeMCU for nodeMCU Tutorial.

Top Articles
Latest Posts
Article information

Author: Merrill Bechtelar CPA

Last Updated:

Views: 6343

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Merrill Bechtelar CPA

Birthday: 1996-05-19

Address: Apt. 114 873 White Lodge, Libbyfurt, CA 93006

Phone: +5983010455207

Job: Legacy Representative

Hobby: Blacksmithing, Urban exploration, Sudoku, Slacklining, Creative writing, Community, Letterboxing

Introduction: My name is Merrill Bechtelar CPA, I am a clean, agreeable, glorious, magnificent, witty, enchanting, comfortable person who loves writing and wants to share my knowledge and understanding with you.