Project 2.3.3: Bluetooth Led Animation Control
Intermediate Embedded Systems Project Using Raspberry Pi Pico 2 W and MicroPython
Overview
This project builds a four-LED animation controller that receives pattern commands over BLE.
A similar approach could be used for indicator panels, wearable art, small status displays, or prototype user feedback systems.
The final system should allow a phone to trigger animations, turn all LEDs on or off, and tune the animation speed.
Required Components
![]() LEDs |
![]() Phone with BLE app |
![]() Raspberry Pi Pico 2 W |
![]() 220Ω resistors |
![]() Breadboard |
![]() Jumper wires |
Circuit Connections
| Component terminal | Connect to | Pico physical pin | Notes |
|---|---|---|---|
| LED 1 anode (+) | 220Ω resistor then GPIO 16 | GPIO 16 / physical pin 21 | Left-most LED |
| LED 2 anode (+) | 220Ω resistor then GPIO 17 | GPIO 17 / physical pin 22 | Second LED |
| LED 3 anode (+) | 220Ω resistor then GPIO 18 | GPIO 18 / physical pin 24 | Third LED |
| LED 4 anode (+) | 220Ω resistor then GPIO 19 | GPIO 19 / physical pin 25 | Right-most LED |
| All LED cathodes (-) | GND | Physical pin 38 | Common ground |
Wiring Diagram

Raspberry Pi Pico 2 W
┌─────────────────────┐
│ │
│ GPIO 16 ────220Ω───┤──── LED 1 (+)
│ GPIO 17 ────220Ω───┤──── LED 2 (+)
│ GPIO 18 ────220Ω───┤──── LED 3 (+)
│ GPIO 19 ────220Ω───┤──── LED 4 (+)
│ │
│ GND ───────────┤──── All LED cathodes (-)
│ │
└─────────────────────┘
Step-by-Step Assembly
Step 1: Place the Raspberry Pi Pico 2W
Place the Raspberry Pi Pico 2W 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 Four LEDs
Place four LEDs in a clear row on the breadboard. For each LED, identify the long leg as the anode (+) and the short leg as the cathode (-).
Step 3: Connect LED 1 to GPIO 16
Connect LED 1 long leg to one end of a 220Ω resistor. Connect the other end of the resistor to GPIO 16.
Step 4: Connect LED 2 to GPIO 17
Connect LED 2 long leg to one end of a 220Ω resistor. Connect the other end of the resistor to GPIO 17.
Step 5: Connect LED 3 to GPIO 18
Connect LED 3 long leg to one end of a 220Ω resistor. Connect the other end of the resistor to GPIO 18.
Step 6: Connect LED 4 to GPIO 19
Connect LED 4 long leg to one end of a 220Ω resistor. Connect the other end of the resistor to GPIO 19.
Step 7: Connect the LED Short Legs
Connect the short leg of each LED to GND.
Step 8: Check the LED Order
Confirm that the left-to-right LED order matches GPIO 16, GPIO 17, GPIO 18, and GPIO 19.
Wiring Check
- [x] Pico 2W is placed correctly across the breadboard center gap
- [x] LED 1 long leg connects through a 220Ω resistor to GPIO 16
- [x] LED 2 long leg connects through a 220Ω resistor to GPIO 17
- [x] LED 3 long leg connects through a 220Ω resistor to GPIO 18
- [x] LED 4 long leg connects through a 220Ω resistor to GPIO 19
- [x] All LED short legs connect to GND
- [x] No loose jumper wires
Intermediate Note This project uses BLE on the Raspberry Pi Pico 2W. Use a BLE app such as nRF Connect, LightBlue, or a BLE UART terminal to connect to
AIDER_LEDAnimand send commands. Keep the LED order consistent so the animation commands match the physical row.
Testing Individual Components
Before running the full project, test each part separately. This makes it easier to find wiring, library, or code problems.
Hardware Setup
- Build all four LED channels carefully
- Label the LEDs from left to right so the chase and wave patterns are easier to interpret
Test the Output Channels
- Run a short script that turns each LED on one at a time
- Fix any wiring issue before testing animations
Test Pattern Timing
- Upload the final code and test one animation from the Shell or BLE app at a time
- Observe whether the pattern order matches the physical LED arrangement
Test Communication
- Connect to
AIDER_LEDAnimfrom the BLE app - Send
blink,chase,wave,pong,status, andspeed 80to verify the command set
Run the Full System
- Try several patterns at different speeds
- Confirm
all onandall offstill work after animations - Decide which timing values make the display easiest to read
Save the Project
- Save the final code after selecting a good default animation speed
- Record which pattern best communicates state for your intended use case
Additional Testing and Calibration Checks
Calibration and tuning notes
- Start with a moderate step delay such as 120 ms, then test slower and faster values
- If the animation looks confusing, increase the delay so the pattern is easier to observe
- If two LEDs seem to swap roles, recheck the physical left-to-right wiring order against the code list
Quick testing checklist
- [ ] Each LED channel works individually
- [ ] BLE app finds
AIDER_LEDAnim - [ ]
blink,chase,wave, andpongcommands all work - [ ]
all onandall offcommands work - [ ]
speedcommand changes the animation timing
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
import bluetooth
import time
from ble_uart import BLEUART
DEVICE_NAME = "AIDER_LEDAnim"
leds = [Pin(16, Pin.OUT), Pin(17, Pin.OUT), Pin(18, Pin.OUT), Pin(19, Pin.OUT)]
ble = bluetooth.BLE()
ble.active(True)
uart = BLEUART(ble, name=DEVICE_NAME)
step_delay_ms = 120
command_queue = []
def send_line(message):
print(message)
uart.write((message + "\n").encode())
def on_rx(data):
command = data.decode("utf-8").strip().lower()
if command:
command_queue.append(command)
def all_off():
for led in leds:
led.off()
def all_on():
for led in leds:
led.on()
def blink_pattern():
for _ in range(3):
all_on()
time.sleep_ms(step_delay_ms)
all_off()
time.sleep_ms(step_delay_ms)
def chase_pattern():
for _ in range(3):
for led in leds:
all_off()
led.on()
time.sleep_ms(step_delay_ms)
def wave_pattern():
for _ in range(3):
for index in range(len(leds)):
leds[index].on()
time.sleep_ms(step_delay_ms)
for index in range(len(leds)):
leds[index].off()
time.sleep_ms(step_delay_ms)
def pong_pattern():
order = [0, 1, 2, 3, 2, 1]
for _ in range(3):
for index in order:
all_off()
leds[index].on()
time.sleep_ms(step_delay_ms)
uart.on_rx(on_rx)
all_off()
send_line("Bluetooth LED animation controller ready")
while True:
if command_queue:
command = command_queue.pop(0)
if command == "blink":
blink_pattern()
send_line("Blink pattern complete")
elif command == "chase":
chase_pattern()
send_line("Chase pattern complete")
elif command == "wave":
wave_pattern()
send_line("Wave pattern complete")
elif command == "pong":
pong_pattern()
send_line("Pong pattern complete")
elif command == "all on":
all_on()
send_line("All LEDs ON")
elif command == "all off":
all_off()
send_line("All LEDs OFF")
elif command.startswith("speed "):
step_delay_ms = int(command.split()[1])
send_line("Animation speed set to {} ms".format(step_delay_ms))
elif command == "status":
send_line("Animation step delay: {} ms".format(step_delay_ms))
elif command == "help":
send_line("Commands: blink, chase, wave, pong, all on, all off, speed <ms>, status, help")
else:
send_line("Unknown command. Send help.")
time.sleep_ms(80)
How the Code Works
| Code Section | What It Does | Why It Matters |
|---|---|---|
| LED list | Stores all four output channels in one structure | Makes repeated animations easier to write |
| Pattern functions | Group the blink, chase, wave, and pong logic | Keeps the command handler simple and readable |
step_delay_ms |
Controls the timing speed for every pattern | Lets students tune the visual behaviour without rewriting the logic |
| BLE command handler | Chooses which pattern or control action to run | Turns the phone into a remote animation controller |
Expected Result
The phone can trigger several LED animations over BLE. Each pattern runs in the expected order and the speed command changes how fast the LEDs move.
Troubleshooting
| Problem | Possible cause | Solution |
|---|---|---|
| One LED never lights | The LED is reversed or the resistor path is broken | Recheck the polarity and the resistor connection for that channel |
| Pattern order looks wrong | The LEDs are wired in a different physical order from the code | Trace each GPIO wire and relabel the LEDs from left to right |
| Animation is too fast or too slow | The step delay is not tuned for the test setup | Use speed <ms> to adjust the timing until the pattern is clear |
| Phone cannot find the BLE device | The Pico is not advertising or the BLE helper files are missing | Confirm ble_uart.py and ble_advertising.py are saved on the Pico, restart the board, and scan again from nRF Connect or LightBlue |
| Commands do not change the system state | The phone is connected to the wrong service or the command text is different from the expected command | Reconnect to the BLE UART service and send the exact command shown in the test section |





