The main objective of this tutorial is to learn how to control two LEDs remotely using an infrared (IR) remote control and an ESP8266 NodeMCU board.
This project demonstrates how to use an IR receiver sensor to capture the signals transmitted by the remote control and how to program the ESP8266 to interpret these signals and control LEDs accordingly.
Through this tutorial, you will:
- understand how infrared communication works between a remote control and an electronic device.
- learn how to connect and interface an IR receiver with the ESP8266 NodeMCU.
- discover how to decode IR signals sent by different buttons on the remote control.
- write a MicroPython program that reads the IR codes and performs actions such as turning LEDs ON or OFF based on the button pressed.
Gain experience in building a simple remote-controlled lighting system, which can later be expanded to control other devices such as motors, relays, or home automation systems.
At the end of this tutorial, you will have a functional system where:
- pressing specific buttons on the remote allows you to turn both LEDs on or off,
- or control each LED individually, showing how an IR remote can easily manage multiple outputs on the ESP8266 board.
ESP8266 NodeMCU Board
The main microcontroller that receives signals from the IR sensor and controls the LEDs.
IR Receiver Module (KY-032)
Captures infrared signals from the remote control and sends them to the ESP8266 as digital codes.
IR Remote Control
Sends infrared signals. Each button emits a unique code that the ESP8266 can interpret to control LEDs.
Two LEDs (e.g., red and blue)
These LEDs will be controlled individually or together by the remote control.
Two 220 Ω Resistors
Limit the current flowing through the LEDs to prevent damage.
Breadboard
For easy connections of all components without soldering.
Jumper Wires
Used to connect the ESP8266, LEDs, and IR receiver on the breadboard.
The system consists of an ESP8266 NodeMCU, an IR receiver, an IR remote control, and two LEDs (red and blue). The components are connected on a breadboard using jumper wires.
1. Connecting the IR Receiver
VCC → 3.3V of ESP8266
GND → GND of ESP8266
OUT → D2 (GPIO4) for signal input
2. Connecting the LEDs
Each LED is connected to a digital pin of the ESP8266 through a 220 Ω resistor:
LED 1 (Red):
Anode (+) → D0(GPIO16) via 220 Ω resistor
Cathode (–) → GND
LED 2 (Blue):
Anode (+) → D1 (GPIO5) via 220 Ω resistor
Cathode (–) → GND
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# More details can be found in TechToTinker.blogspot.com # George Bantique | tech.to.tinker@gmail.com from machine import Pin from ir_rx import NEC_16 # Define LEDs led_rouge=Pin(16, Pin.OUT) led_bleue=Pin(5, Pin.OUT) ir_gpio=Pin(4, Pin.IN) def ir_callback(data, addr, ctrl): global ir_data global ir_addr if data > 0: ir_data = data ir_addr = addr print('Data {:02x} Addr {:04x}'.format(data, addr)) ir = NEC_16(ir_gpio, ir_callback) ir_data = 0 ir_addr = 0 led_rouge.value(0) # eteindre LED rouge led_bleue.value(0) # eteindre LED bleue while True: if ir_data > 0: if ir_data==0x0C: # on appuie sur la touche 1 de la télécommande led_rouge.value(1) # allumer LED rouge led_bleue.value(1) # allumer LED bleue if ir_data==0x18: # on appuie sur la touche 2 de la télécommande led_rouge.value(0) # eteindre LED rouge led_bleue.value(0) # eteindre LED bleue if ir_data==0x08: # on appuie sur la touche 4 de la télécommande led_rouge.value(1) # allumer LED rouge led_bleue.value(0) # eteindre LED bleue if ir_data==0x1C: # on appuie sur la touche 5 de la télécommande led_rouge.value(0) # eteindre LED rouge led_bleue.value(1) # allumer LED bleue ir_data = 0 |
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.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info