Wav player with RPG-based menu

Project by Josh Dunn and Ryan Sartin

Purpose

This simple audio player utilizes an LCD, RPG (Rotary Pulse Generator), 8 ohm speaker, and SD card to provide the basic functions of a music player.

Description

Upon start-up the project checks to see if an SD card is inserted. If one is found then then the SD card will be searched for all files with a .wav or .WAV extension (the default search location is "/sd/"). Whenever a wave file is found, it's path name is stored in a new node of a doubly-linked list. Once the search has been completed, the total number of wave files found will be displayed on the LCD screen.

From there the RPG will allow the user to scroll through the list of files. Turning the RPG clockwise increments through the linked list and counter-clockwise decrements. When the RPG push-button is pressed, the LCD displays "Song Playing" and uses the path name stored in the current node of the linked-list to open the wave file. The header information is read from the wave file and the total length of the song in seconds is calculated using the equation: total length / (samples per second * number of channels * bytes per sample). This is displayed on the second row of the LCD screen in the format: "Time: /XXXsec", where XXX is the recently calculated number (left justified). The file is closed after the header information is read. Then the Ticker API is initialized with a function that counts the number of elapsed seconds and the file is re-opened. The wave_player library is then used to play the song from the SD card. While playing the ticker function will seize control and count the number of seconds and print it out to the second row of the LCD screen.

If the SD card is ever removed during operation, the LCD will display "No SD card Found" and the mbed will need to be reset. The linked-list will be freed.

Pictures

/media/uploads/rsartin3/song_1.jpg

After program initialization, the audio player searches the SD card for usable .wav files and displays the number on the screen. The user uses the RPG to cycle left and right between the available file names.

/media/uploads/rsartin3/song.jpg

As the user scrolls through the available .wav file choices, the file name is displayed on the LCD (without the .wav file extension).

/media/uploads/rsartin3/song_2.jpg

After the song is selected by the user (shown above), the LCD displays the time elapsed and total song time once the sound begins to play.

Video

Schematic

Speaker and NPN transistor connections

/media/uploads/rsartin3/untitled-1.png

Information

You can place a diode in parallel with the speaker, as shown here. This flyback diode is used to eliminate sudden voltage spikes across inductive loads when the power supply is reduced or removed. It is highly recommended to use such a diode for large loads such as motors.

SC Card breakout board and RPG connections

/media/uploads/rsartin3/mbed_sch_left_2.png

LCD connections

/media/uploads/rsartin3/mbed_sch_right_2.png

Parts

  • NPN Bipolar Junction Transistor (BJT)
  • 1k Ohm Resistor
  • 520 Ohm Resistor

Pins

Note

As always, fully disconnect power from your circuit before making changes, even simple wire addition/removal.

LCD Assignments
PinTextLCD pinsmbed pins
1GND0V
2VCC5.0V
3VO0V, via 1k resistor
4RSp25
5RW0V
6Ep26
7D0not connected
8D1not connected
9D2not connected
10D3not connected
11D4p27
12D5p28
13D6p29
14D7p30
RPG Assignments
PinRPG pinsmbed pins
16p16
27p17
380V
49p19
SD Card Assignments
PinSD pinsmbed pins
1cdp9
2dop6
3GND0V
4sclkp7
5VCC3.3V
6dip5
7cs (chip select)p8
Speaker Assignment
PinSpeaker pinmbed pins
1via 520 ohm resistor to NPN BJT Basep18

Program

Import programWav_player_RPG_menu

This program utilizes an LCD, RPG, 8 ohm speaker, and SD card to provide the basic functions of a music player. The project cycles through the SD card for .wav files and tracks elapsed time. See http://mbed.org/users/rsartin3/notebook/wav-player-with-RPG-based-menu/ for more information.

Additional Resources

Further Improvements

  • Allow the user to freely remove and insert SD card when songs are not playing


1 comment on Wav player with RPG-based menu:

03 Jul 2013

hey how would you use this with a usb pen drive on the Components Workshop Board thanks

Please log in to post comments.