I need with making my own music using a piezo element

So I recently finished doing the tutorial about using the Piezo element to play music. Now as a project extension I want to play different music using the Piezo element.

What parts of the code should I change to help compensate? Also what's a good amount of maximum notes to have so my computer doesn't take forever to compile the code?

Thanks

Please post the code you're trying to modify. I'm afraid I have no idea what "the tutorial about using the Piezo element to play music" looks like.

In most such programs there is an array of notes and an array of note durations and both will need changing. You can have as many notes as you're willing to work out. Compile time isn't a problem but memory could be if you get up into the hundreds or thousands of notes (depending on what Arduino you're using).

Steve

The arduino can't play mp3 files without a shield, since it can't handle or interpret the file itself. I don't know if that is what you are trying to do, but I have tried this myself and I am afraid you will have to use a shield for mp3 files.

If you are trying to play notes with a piezo library (which I think is what you mean), you need to show us the code you are using, there are many libraries and they all work differently.

Hey Steve, I meant the Circuit 6 tutorial, I could understand why that would be confusing looking back. I will link the code:

https://www.arduino.cc/en/Tutorial/PlayMelody

I am still interested in how to change this code to play your own songs, although I have found another (less confusing) way to do it with arrays.

Thanks!

To change the melody, change the notes and note timings in the two arrays below.

Did you see the helpful comments in the code?

//  melody[] is an array of notes, accompanied by beats[],
//  which sets each note's relative length (higher #, longer note)
int melody[] = {  C,  b,  g,  C,  b,   e,  R,  C,  c,  g, a, C };
int beats[]  = { 16, 16, 16,  8,  8,  16, 32, 16, 16, 16, 8, 8 };