Blink two LEDs by ESP8266 NodeMCU board

ESP8266 03-10-25
15 0

Tutorial plan

1- Objective of this tutorial

2- The components needed to control two LEDs by ESP8266 NodeMCU

3- Mounting ESP8266 NodeMCU card with two LEDs

4- Program ESP8266 NodeMCU with MicroPython

 

 

Objective of this tutorial

The objective of this tutorial is to learn how to control two LEDs using the ESP8266 NodeMCU development board. By the end of the tutorial, you will understand how to connect LEDs to the microcontroller, write a simple MicroPython program to make them blink alternately or simultaneously, and observe how digital output pins can be used for basic electronic control.

This exercise introduces beginners to the fundamentals of programming GPIO pins and lays the foundation for more advanced IoT and embedded systems projects.

The components needed to control two LEDs by ESP8266 NodeMCU

1. ESP8266 NodeMCU Board

The main microcontroller that will be programmed to turn the LEDs on and off.

Two LEDs (Light Emitting Diodes) 

The output devices that will blink according to the program.

Two Resistors (220Ω – 330Ω)

deux résistances

They are used in series with the LEDs to limit current and prevent them from burning out.

Breadboard

plaque d'essai

A prototyping board to easily connect all the components without soldering.

Jumper Wires

Fils de connexion

They make the electrical connections between the NodeMCU, resistors, and LEDs.

 

Mounting ESP8266 NodeMCU card with two LEDs

1- Place the NodeMCU on the Breadboard

2- Place the red LED on the breadboard.

3- The anode (long leg, +) will connect to one leg of a 220Ω resistor

4- The other leg of the resistor should go to D0 (DPIO16)

5- The cathode (short leg, –) will connect to GPIO pin of ESP8266

6- Place the blue LED on the breadboard.

7- The anode (long leg, +) will connect to one leg of a 220Ω resistor

8- The other leg of the resistor should go to D1 (DPIO5)

9- The cathode (short leg, –) will connect to GPIO pin of ESP8266

 

Program ESP8266 NodeMCU with MicroPython

 

Explanation of the Program

from machine import Pin → Imports the Pin class to control GPIO pins.

import time → Used for delays (sleep function).

red_led = Pin(16, Pin.OUT) → Configures GPIO16 (D0) as output for the red LED.

blue_led = Pin(5, Pin.OUT) → Configures GPIO5 (D1) as output for the blue LED.

Inside the while True: loop, the LEDs blink alternately with a 2 second delay.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info