How to change volume of sound

I am making an alarm system. I want it to beep quietly and then, after an interval of time, beep loudly.

How would I change the volume a sound from my sketch?

Thanks in advance!

sciencekid:
I am making an alarm system. I want it to beep quietly and then, after an interval of time, beep loudly.

How would I change the volume a sound from my sketch?

Thanks in advance!

Cover your ears, and then uncover them 8)

What will the sound be coming from in the end? piezo, speaker?

You are missing a piece, Crossroads. The digital pot should be hooked up to this:

That would work to drive a speaker.

trying to drive a piezo.

I'm interested in the piezo end as well.

I bought 100 10mm discs with leads for $10.30 and so far I only use then for buttons and knock sensors.

Maybe they have to have the plastic housing to make much noise?
I double-stick taped them to plastic cup base and small cookie tin lids and got sound but not much.

Some day, I'd like to make one able to pick up sound and find frequency, for example.

But I do luv piezos. They're like capacitors that you can charge by touch, discharge by release.

http://www.murata.com/products/catalog/pdf/p37e.pdf
See page 12 for an example to drive a raw piezo element (vs a self contained unit).
The frequency can be from Arduino, driving 1K resistor and NPN/resistor/piezo element.

If you want it quieter, can use a frequency with a lower output level.

GoForSmoke:
I bought 100 10mm discs with leads for $10.30 and so far I only use then for buttons and knock sensors.
Maybe they have to have the plastic housing to make much noise?
I double-stick taped them to plastic cup base and small cookie tin lids and got sound but not much.

10 mm? No wonder they do not make much noise.

The plastic cup is a good idea.

They need plenty of voltage (driven push-pull by two outputs) and only work best at their resonant frequency, which you have to figure. That said, their propensity for generating excess voltages is such that you need a resistor - 470 ohm or so - to avoid them causing problems for the MCU.

BulldogLowell:
Digital Potentiometer - 10K - COM-10613 - SparkFun Electronics

Gross overkill in this situation; the better answer is to use two outputs with two different resistors to provide the different volumes.

That page is however, grossly confusing as well where it suggests

or the ‘mood lighting’ in your room

So now we have people thinking that a "digital potentiometer" is a meaningful way to control their 220V lighting, or their 10W LED strips.

Those chips come in potentiometer and rheostat versions.
I'm a bit foggy on the differences except IIRC a rheostat is capable of carrying more current.