Music Player
Compact music player with microSD input, outputting to a speaker, featuring controls for play, pause, skip, and volume.
Author: Pasaroiu Mihai Octavian
GitHub Project Link: https://github.com/UPB-FILS-MA/project-12mihai05.git
Description
This project is a compact music player built with a Raspberry Pi Pico W and programmed in Rust. It uses an SPI-connected microSD module to read songs, playing them through a speaker with an amplifier for clear audio output. The music will be outputted as PWM through a speaker. The user interface consists of push buttons for basic controls (next song, previous song, and play/pause), a potentiometer for smooth volume adjustment, and an I2C LCD screen that displays the current song's title. Additionally, a set of PWM-controlled LEDs offers a dynamic visual representation of the music's intensity, with brightness varying based on the PWM duty cycle of the audio output to the speaker.
Motivation
Building a music player with a Raspberry Pi Pico W using Rust allowed me to work on a project that I could personally enjoy, while also learning valuable skills in microcontroller programming and hardware integration. I like to listen to music, and it seemed interesting to create a project that combines technology with something I love. Plus, it's a great way to make something cool that I can show off to my friends.
Architecture
Log
Week 6 - 12 May
Make the hardware part and work for the software.
Week 7 - 19 May
Continue developing and debugging software.
Week 20 - 26 May
Finished the software and made the case for the project.
Hardware
This project utilizes a Raspberry Pi Pico to facilitate digital audio playback from a 32GB microSD card formatted in FAT32, interfaced via SPI protocol. The audio output is delivered through a 1W speaker powered by a PAM8403 Class D Stereo Mini Amplifier, enhanced by an RC filter comprising a 680-ohm resistor and a 10nF capacitor, which filters frequencies above 23.4kHz. Visual augmentation is achieved through four LEDs, controlled by PWM signals that vary in intensity corresponding to the audio output's duty cycle, providing a dynamic representation of sound intensity. User interaction is managed through a 1602 LCD display, operating on the I2C protocol, which displays the current song title. The system also incorporates three push-buttons connected to the microcontroller's GPIO pins with 10k-ohm pull-up resistors, assigned to play/pause functionality and navigation between tracks. Additionally, a potentiometer is integrated for volume control, offering user-adjustable audio output levels.
Schematics

Bill of Materials
| Device | Usage | Price |
|---|---|---|
| Rapspberry Pi Pico W | The microcontroller | 35 RON |
| 1602 LCD | LCD Display | 16.34 RON |
| Amplifier | Boosts audio output | 3.99 RON |
| Buttons | Play/Pause and previous/next song | 2.16 RON |
| Different color leds | Visual representation of the music's intensity | 6 RON |
| Wires | Connects electronic components | 13.79 RON |
| Breadboard | Component integration | 9.98 RON |
| Potentiometer | Adjust volume | 2.36 RON |
| Speaker | Outputs the song | 4.27 RON |
| Resistors | Limits current flow | 14.99 RON |
| MicroSD Card Module | Reads the song from the microSD | 4.39 RON |
| Capacitor | Low-pass filter(RC) | 0.39 RON |
Software
| Library | Description | Usage |
|---|---|---|
| embedded-sdmmc-rs | MicroSD card management | Used for reading the files from microSD |
| ag-lcd | LCD display driver | Used for displaying the name of the song playing |
| port-expander | Management and use of I/O expander chips | Manage the PCF8574 I/O expander for controlling LCD display via the I2C bus |
| cortex-m | Provides low-level APIs for ARM Cortex-M processors | Interrupt handling and system control |
| embassy-executor | Manages asynchronous tasks | Handles logging over USB in an asynchronous manner |
| embassy-sync | Provides synchronization primitives for use in async tasks | Used to protect shared resources using mutexes |
| embassy-time | Provides time-related utilities | Managing delays and scheduling tasks |
| heapless | Enables the use of fixed-size data structures that do not require heap memory | Managing strings and vectors that have a fixed capacity |
| log | Facilitates logging | Output debug and information messages |
| microfft | Provides fast Fourier transform (FFT) calculations | Performing FFT on audio data to analyze frequencies and amplitudes |
| bytemuck | Offers safe casting between data types | Used to safely cast slices of bytes to slices of other types |
| fixed | Implements fixed-point arithmetic types | Transform bytes in FixedU16 |
Links
- How to connect SD Card to Raspberry Pi Pico using SPI
- How to use the LCD using I2C
- Check and search for dependecies: 1, 2
- Example of how to play music using PWM
- Audio output circuit example