kitchen timer, make noise

Hi,

I'm making a kitchen timer, not that I need one but because I wanted to play with a rotary encoder and a 4 digit TM1637 based display.
I need advice about how to make it play some really annoying sound when it finish.
At the moment I only have a small piezzo disk (aprox 15mm diameter) without any amplification, but when placed over a cheap plastic box it makes enough noise. This might change, as it is it is using 2 pins, if I can make it use only one pin for the alarm I might try to port this to the Attiny85 (two pins for the display, two for the rotary encoder, one for the switch/button and one for the audio, I'll have to use the reset pin but it might work).

This is the code I'm running when the timer runs out.
How can I make the sound even more annoying, this is not only a question be being heard, I want to make it very hard to be ignored. Is there some "magic" tone/silence sequence guaranteed to make you take notice ?

NOTE: function reset() resets the Arduino, function sw() returns true if a button is pressed, SEG_STOP is an array with the patterns to display StOP on the TM1637 display. The tone library being used is toneAC instaled with the Arduino Library Manager.

void done()
{
    long x;

    x=millis();
    while(1)
    {
            if(sw()) reset();
            toneAC(2600);
            display.setBrightness(0, true);
            display.setSegments(SEG_STOP);
            delay(50);
            toneAC(0);
            delay(10);
            toneAC(4000);
            display.setBrightness(7, true);
            display.setSegments(SEG_STOP);
            delay(50);
            toneAC(0);
            delay(10);
            if(millis()>(x+60000L)) reset();
    }
}

ocsav:
...if I can make it use only one pin for the alarm I might try to port this to the Attiny85

The toneAC() library is AFAIK designed to drive a piezo in bridge-mode between two pins, for a slightly higher sound output.
The default tone() function only uses one pin.
Not sure about timers for an Attiny85.
Leo..

Yes, as far as I understand the volume of the sound that comes out of a piezo is function of the applied voltage.
But I know that an Arduino pin cannot go negative related to GND so I don't really know why this make a difference.
If I move one of the pins to GNC or VCC I get about half the volume.

After sleeping over the problem I'm thinking that the best solution would be to use one pin to turn on a mosfet that will feed some type of 555 based noisemaker.
I can't make it very loud as it will be running from batteries, so I must make it very annoying. :wink:
So the initial question remains, what makes an alarm sound really difficult to ignore ?

ocsav:
But I know that an Arduino pin cannot go negative related to GND so I don't really know why this make a difference.

But the voltage on the piezo can be reversed when connected between two pins,
making it possible for the piezo crystal to move up/back/down (twice the distance than only up/back).
Not sure if you should call that "twice as lound".
Leo..

Wawa:
Not sure if you should call that "twice as loud".

6 dB up.

Wawa:
But the voltage on the piezo can be reversed when connected between two pins,
making it possible for the piezo crystal to move up/back/down (twice the distance than only up/back).
Not sure if you should call that "twice as lound".
Leo..

I don't understand, if I have 1 pin at GND and use the other to make sound the voltage can go from 0V to 4.5V or whatever VCC really is, but with 2 pins, if the minimum is GND anyway how can the distance be double ? Sorry if this question is basic but I lack almost any theoretical bases.
My scope is single channel (and very basic) so I can't compare the two signals but I will take a look anyway.

"twice as loud" based on my ears, not in any measuring.

I need help in another subject, I implemented single click and long click without problem but double and triple click eludes me, I don’t see how I should do it.

Could you recommend a good button library that does not mess the interrupts so much that causes problems with millis() ? I need single, long, double and triple click.

I’m already using

name=RotaryEncoder (used without interrupts)
version=1.1.0
author=Matthias Hertel
url=http://www.mathertel.de/Arduino/RotaryEncoderLibrary.aspx

name=toneAC
version=1.5.0
author=Tim Eckel tim@leethost.com
url=https://github.com/teckel12/arduino-toneac

and

name=TM1637
version=1.2.0
author=Avishay Orpaz avishorp@gmail.com
url=https://github.com/avishorp/TM1637

Multiple click presses can be achieved with a counter and a simple timer.

example:
On the first click you start a timer.
Each click increments a counter.
If the counter is equal to three when the timer expires, you have detected a triple click (at which time you reset the counter and do your stuff).
No library needed.