Project 1.5.1: IR Remote LED Controller
Beginner Embedded Systems Project Using Raspberry Pi Pico 2 W and MicroPython
Pico 2 W Diagram
Overview
Build an LED project that responds to an infrared remote control.
This project demonstrates wireless control and decoding remote button codes.
The final result is an LED that turns on or off when selected remote buttons are pressed.
Required Components
![]() Raspberry Pi Pico 2 W |
![]() IR receiver module |
![]() LED |
![]() 220 Ohm resistor |
![]() Breadboard |
![]() Jumper wires |
![]() IR remote control |
Circuit Connections
| Component Pin | Connects To | Pico GPIO / Physical Pin Number | Notes |
|---|---|---|---|
| IR receiver VCC | 3.3V | Physical pin 36 | Check module pin order |
| IR receiver GND | GND | Physical pin 38 | |
| IR receiver OUT | GPIO 1 | GPIO 1 / physical pin 2 | Signal pin |
| LED anode (+) | 220 Ohm resistor then GPIO 0 | GPIO 0 / physical pin 1 | |
| LED cathode (-) | GND | Physical pin 38 |
Step-by-Step Assembly
Step 1: Place the Raspberry Pi Pico 2 W
Place the Raspberry Pi Pico 2 W on the breadboard so it sits across the center gap.
Keep the USB port facing outward so you can easily connect it to your computer.

Step 2: Place the IR Receiver Module
Insert the IR receiver module onto the breadboard.
Most IR receiver modules have three pins:
- VCC
- GND
- OUT / Signal
Check the labels on your IR receiver module before wiring, because the pin order may be different depending on the module.

Step 3: Connect the IR Receiver VCC Pin
Connect the VCC pin of the IR receiver module to 3.3V on the Raspberry Pi Pico 2 W.

Step 4: Connect the IR Receiver GND Pin
Connect the GND pin of the IR receiver module to a GND pin on the Raspberry Pi Pico 2 W.

Step 5: Connect the IR Receiver OUT Pin
Connect the OUT or Signal pin of the IR receiver module to GPIO 1 on the Raspberry Pi Pico 2 W.
This pin sends the remote-control signal to the Pico.

Step 6: Place the LED
Insert the LED onto the breadboard.
- Place the long leg (anode, +) in one row.
- Place the short leg (cathode, -) in a different row.
Do not place both LED legs in the same breadboard row.

Step 7: Connect the LED Long Leg to the Resistor
Insert one end of the 220 Ohm resistor into the same row as the LED's long leg.

Step 8: Connect the Resistor to GPIO 0
Connect the other end of the 220 Ohm resistor to GPIO 0 on the Raspberry Pi Pico 2 W.

Step 9: Connect the LED Short Leg to GND
Connect the LED's short leg to a GND pin on the Raspberry Pi Pico 2 W.

Wiring Check
Before running the code, confirm:
- Pico 2 W is placed correctly across the breadboard center gap.
- IR receiver VCC connects to 3.3V.
- IR receiver GND connects to GND.
- IR receiver OUT / Signal connects to GPIO 1.
- LED long leg connects to the 220 Ohm resistor.
- Resistor connects to GPIO 0.
- LED short leg connects to GND.
- No loose jumper wires.
!!! note "Beginner Note"
Point the IR remote directly at the IR receiver when testing. If the receiver does not respond, check the module pin labels again and make sure the remote battery is working.
Testing Individual Components
Before running the full project, test each part separately. This makes it easier to find wiring or code problems.
LED Test
Check the LED output first.
from machine import Pin
import time
led = Pin(0, Pin.OUT)
led.on()
time.sleep(1)
led.off()
Expected test result: The LED turns on briefly, then off.
IR Code Reader Test
Find the button codes from your own remote.
from machine import Pin
from ir_rx.nec import NEC_8
import time
def callback(data, addr, ctrl):
if data >= 0:
print('Code:', hex(data), 'Address:', hex(addr))
ir = NEC_8(Pin(1, Pin.IN), callback)
print('Press remote buttons now')
while True:
time.sleep(0.2)
Expected test result: The Shell prints a hexadecimal code when you press remote buttons.
Full Project Code
After completing and checking the circuit connections, open Thonny IDE. Copy and paste the code below into a new file, or upload the project file to the Raspberry Pi Pico 2 W, then run it from Thonny.
from machine import Pin
from ir_rx.nec import NEC_8
import time
led = Pin(0, Pin.OUT)
led.off()
TURN_ON_CODE = 0x45
TURN_OFF_CODE = 0x46
def callback(data, addr, ctrl):
if data < 0:
return
print('Received:', hex(data))
if data == TURN_ON_CODE:
led.on()
print('LED ON')
elif data == TURN_OFF_CODE:
led.off()
print('LED OFF')
ir = NEC_8(Pin(1, Pin.IN), callback)
print('IR LED control ready')
print('Replace TURN_ON_CODE and TURN_OFF_CODE with your remote values if needed')
while True:
time.sleep(0.2)
How the Code Works
| Code Section | What It Does | Why It Matters |
|---|---|---|
| Library import | Loads NEC IR support from the ir_rx folder |
The Pico needs a decoder for remote signals |
TURN_ON_CODE / TURN_OFF_CODE |
Stores the chosen remote button codes | Lets students match their own remote buttons |
callback() |
Runs automatically when an IR code is received | This is where the LED action happens |
| Infinite loop | Keeps the program alive | The decoder needs the script to continue running |
Expected Result
When you press the remote button that matches TURN_ON_CODE, the LED turns on. When you press the button that matches TURN_OFF_CODE, the LED turns off.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| No remote codes appear | Wrong library files or receiver wiring | Check the ir_rx folder and the receiver pin order |
| Codes appear but LED does not respond | TURN_ON_CODE or TURN_OFF_CODE do not match your remote |
Use the code reader test and update the values |
| Strange repeated output | Remote repeat signal | Ignore negative repeat values as shown in the callback |






