user31239: I am using a piezo buzzer and fiddling around with it a little bit. I currently have different tones with delays in between and I have to do a lot of trial and error for the piezo buzzer to play sounds like I want it to. Is there a better way to do this? because at this rate I will be stuck for a while. 
I am trying to get the piezo buzzer to make the sound of an alarm. Any suggestion on how I can get it to sound exactly like an alarm or is trial and error the only way?

user16085: It's very hard to know from your question what you are having trouble with.  I have a piano and I can hit the keys, but it takes me a long time to hit them in the right order and with the right timings to create a new symphony.
Anyway, if creating the sounds is the problem, have you looked at the Tone library?
Different alarms have different sounds.  I once heard an alarm which sounded like the start of Fuer Elise, so probably the notes were E and D#.  That would make their frequencies about 330Hz and 311Hz:
void loop()
{
    tone(pin, 330, 250);
    delay(300);
    tone(pin, 311, 250);
    delay(300);
}

The sound you linked to sounds to me like it starts on a C, and slides up gradually one octave.  One octave higher is double the frequency, so this code should do that:
void loop()
{
    const int startFreq = 523;  // C5 is 523Hz

    // Start at the given freqency, and increase gradually by
    // one octave (double the frequency)
    for (int freq=startFreq ; freq<= (startFreq*2) ; ++freq)
    {
        tone(pin, freq, 10);
        delay(3);
    }
}


31239: <p>I am using a piezo buzzer and fiddling around with it a little bit. I currently have different tones with delays in between and I have to do a lot of trial and error for the piezo buzzer to play sounds like I want it to. Is there a better way to do this? because at this rate I will be stuck for a while. </p>

<p>I am trying to get the piezo buzzer to make the sound of an alarm. Any suggestion on how I can get it to sound exactly like an alarm or is trial and error the only way?</p>
 16085: <p>It's very hard to know from your question what you are having trouble with.  I have a piano and I can hit the keys, but it takes me a long time to hit them in the right order and with the right timings to create a new symphony.</p>

<p>Anyway, if creating the sounds is the problem, have you looked at the <a href="https://www.arduino.cc/en/Reference/Tone" rel="nofollow noreferrer">Tone library</a>?</p>

<p>Different alarms have different sounds.  I once heard an alarm which sounded like the start of <a href="https://www.youtube.com/watch?v=_mVW8tgGY_w" rel="nofollow noreferrer">Fuer Elise</a>, so probably the <a href="http://makingmusicfun.net/images/thumbs/fur-elise.jpg" rel="nofollow noreferrer">notes</a> were <code>E</code> and <code>D#</code>.  That would make their <a href="http://www.phy.mtu.edu/~suits/notefreqs.html" rel="nofollow noreferrer">frequencies</a> about 330Hz and 311Hz:</p>

<pre><code>void loop()
{
    tone(pin, 330, 250);
    delay(300);
    tone(pin, 311, 250);
    delay(300);
}
</code></pre>

<p>The sound you <a href="https://www.youtube.com/watch?v=lo4yJbjkMWA" rel="nofollow noreferrer">linked to</a> sounds to me like it starts on a C, and slides up gradually one octave.  One octave higher is double the frequency, so this code should do that:</p>

<pre><code>void loop()
{
    const int startFreq = 523;  // C5 is 523Hz

    // Start at the given freqency, and increase gradually by
    // one octave (double the frequency)
    for (int freq=startFreq ; freq&lt;= (startFreq*2) ; ++freq)
    {
        tone(pin, freq, 10);
        delay(3);
    }
}
</code></pre>
