Arduino Music Player

Hi everyone.

Yesterday, I was surfing on the Internet and searching for projects that I could make on Arduino.
I saw this lady making an electronic piano keyboard with songs in it. I had an LCD Keypad Shield lying around so I thought I could make a music player where there is a small menu with songs and the user can choose it.

You can see the final version of my project above.

Step 1: What You'll Need

For this project you need;

  • Arduino Uno
  • Breadboard
  • LCD Keypad Shield
  • Buzzer
  • 330 ohm resistor
  • Jumpers

Step 2: What You Need to Know

You need to know a little bit about the structure of LCD Keypad Shield. I put the pinout of it so you can see what is what.

As you will see in the code; pin number 4, 5, 6, 7, 8 and 9 are used by the LCD.
Pin 10 is for controlling the backlight of the LCD but you won't need it.
In the circuit, buttons are connected to A0 pin.

That leaves us with digital pins 0, 1, 2, 3, 11, 12, 13 and analog pins A1, A2, A3, A4, A5 free.

—————————

Also you need to know the analog values of each button so that you can identify them. I read A0 value and printed it on serial monitor to find out. Here's a sample code:

int btn_value = 0;
void setup() {
	Serial.begin(9600);
}
void loop() {
	btn_value = analogRead(A0);
	Serial.println(btn_value);
} 

Here are values that I found for my shield:

  • Right Button - 0
  • Up Button - 131
  • Down Button - 306
  • Left Button - 481
  • Select Button - 722
  • No Button - 1023

Step 3: Circuit Design

The circuit is pretty simple.

  • Place your buzzer somewhere on the breadboard.
  • Connect one side of the 330 ohm resistor to the negative pin of the buzzer and the other side to the ground pin of Arduino.
  • Connect the positive pin of the buzzer to pin2 on Arduino.

You're done!
Now let's get to the coding.

Step 4: Code

As you open the archive file, you'll see the following files; lcd_keypad_songs, fur_elise, james_bond, jingle_bells, mario_bros_theme, mario_bros_underworld, merry_christmas, pitches.h

  • lcd_keypad_songs is the main file where the menu and the definitions are written. It is filled with the comments so you can examine and understand the code.
  • pitches.h includes the definition of music notes.
  • Rest of the files include functions of the songs. You can go through them and try to understand. I didn't write the codes for the songs, I found them by searching. So you can also find or write your own songs and add it to the menu.

You have to put them under the same folder. Then you need to open lcd_keypad_songs file with Arduino IDE and upload the code.

Note: james_bond song is not on the menu (it is commented). This is because Arduino has limited space and these songs take up a lot memory. You can always uncomment it and comment another song to listen. You also need to change the menu orders.

Step 5: Done!

Congratulations!

You made it.
If you have any questions or problems, feel free to comment or message me. I would love to help.

Happy Making!

Arduino Contest 2019

This is an entry in the
Arduino Contest 2019

Share

    Recommendations

    • Tape Contest

      Tape Contest
    • Trash to Treasure

      Trash to Treasure
    • Arduino Contest 2019

      Arduino Contest 2019

    Discussions