Arduino Buzzer - how to make melodies/songs ?

Hi team, :slight_smile:

I have a buzzer attached to my arduino uno.

i want to know is there any tool for making songs,melodies etc. like super mario etc.

i have the following code that plays a single melody for now. I dont know how to make another.

'/*
* Play a simple tune using a piezzo
* Based on example created by Tom Igoe
* http://arduino.cc/en/Tutorial/Tone
*/

// Make sure the file pitches.h is placed in the same folder as this sketch
#include "pitches.h"

// Piezzo element connected to Arduino pin 12 and ground
const int buzzerPin = 13;

// Array with the notes in the melody (see pitches.h for reference)
int melody[] = {NOTE_A4, NOTE_A4, NOTE_A4, NOTE_F4, NOTE_C5, NOTE_A4, NOTE_F4, NOTE_C5, NOTE_A4, NOTE_E5, NOTE_E5, NOTE_E5, NOTE_F5, NOTE_C5, NOTE_A4, NOTE_F4, NOTE_C5, NOTE_A4};

// Array with the note durations: a quarter note has a duration of 4, half note 2 etc.
int durations[] = {4, 4, 4, 5, 16, 4, 5, 16, 2, 4, 4, 4, 5, 16, 4, 5, 16, 2};

int tempo = 120; // tempo for the melody expressed in beats per minute (BPM)

void setup() {
  playTune(melody, durations, tempo);
}

void loop() {
  // no need to repeat the melody.
}

void playTune(int notes[], int durations[], int BPM)
{
  int tuneSize = sizeof(melody) / sizeof(int);
  
  // iterate over the notes of the tune:
  for (int thisNote = 0; thisNote < tuneSize; thisNote++) {

    // For details on calculating the note duration using the tempo and the note type,
    // see http://bradthemad.org/guitar/tempo_explanation.php.
    // A quarter note at 60 BPM lasts exactly one second and at 120 BPM - half a second.
    
    int noteDuration = (int)((1000 * (60 * 4 / BPM)) / durations[thisNote] + 0.);
    tone(buzzerPin, notes[thisNote],noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 20% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.20;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(buzzerPin);
  }
}

What kind of buzzer do you have?

Can you read sheet music? You'll need to in order to be able to translate the melody into notes to play on the Arduino.

active buzzer
have 3 pins SIG \ VCC \ GND
I can read. i am not a professional but i do understand it.
but i don't know how to translate it to code ?
Ok note for example
264 Hz - C, do
297 Hz - D, re
330 Hz - E, mi
352 Hz - F, fa
396 Hz - G, sol
440 Hz - A, la
495 Hz - B, si
528 Hz - C, do
but how do i read it from a complex sheet of song or melody?
any tool ?

Have a look here: