Please help: How to produce two "Beeps"?

Hi everybody,

Can anybody help me in programming Arduino to ma one clear single "beep" sound when I touch a botton and another clear single "beep" sound when I release it?

P.s. I'm using an active buzzer to produce the sound and a 3V battery to feed it.

Thanks in advance for your help

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you tell us your electronics, programming, arduino, hardware experience?

Thanks… Tom… :slight_smile:

Have you programmed the Arduino to make a beep at all ?

Use state change detection, then you can easily beep upon press and beep upon release.

Assuming that he/she can beep in the first place

Thank you both for your quick answers,
actually I'm not sure what is "state detection" program (I'm really ignorant using Arduino). Is there a code? Can you send it to me?

Google is your friend.

Time to learn the most important skill for a programmer :slight_smile:
https://www.google.com/search?q=arduino+state+change+detection

Pieter

Contained in the IDE is the state change example. Look under examples in the file menu under basics.

We tend to assume if you are new to the Arduino you will have already explored these as they give examples of key concepts.

The StateChangeDetection example will show you how to detect a button being pressed or released but you have still not said whether you know how to make a beep

Some points to ponder:

  • Can the beep's programmed length be longer than the time the button is held, and if so, what should happen?
  • Does the rest of your program need to (be able to) do anything else while the beeps are sounding?

Thank you anybody for your concern,

I'm going to give some more details:

  • The beep should last just a second (not as long as the time the button is held)

  • There isn't any other action the program should do

Just make a clear singel "Beep" when I press the button and another clear single "Beep" when I release it.

Would it work simply using the "State Change Detection" program after I have connected the active Beeper on the output and the V3 battery on the input or should I make other things or use other codes?

Thanks again

Are you saying the 'so called' beeper is an "active Beeper".

This implies it makes a beep by itself when voltage is applied.

Let's see a link to your beeper. :slight_smile:

If you press and hold the switch down for 4 seconds:

  • do you want a 1 sec. beep at the beginning of the push
    and
  • a second beep after the 4 sec. when you let go?

What happens if you hold the switch down for only one half (1/2) a second?

Let's see your current progress on your sketch.

You will have to actively start and stop the beeper.

Look at the Blink without Delay example on how to do this while also be able to read the button at the same time. You need that for the half second button press situation.

Didn't your teacher tell you anything on how to do this? (must be a class project, as I don't see any practical application of this).

With the beeper at 3V and presumably the digital output at 5V, we will need have the 5V switch the 3V with a transistor, will we not.

(Or can a nominal 3V beeper take 5V?)

Also need to know the current the beeper will draw OP.... I'm wondering if the beeper can just be on a digital pin, like an led, but as larryd says:

Let's see a link to your beeper


What happens if you hold the switch down for only one half (1/2) a second?

You need that [bwod] for the half second button press situation.

Seems like there is no half-second situation:

The beep should last just a second (not as long as the time the button is held)

.... so the beep is always shorter than the button push? And with:

There isn't any other action the program should do

.... this code can get away with using delay().

meltDown:
Seems like there is no half-second situation:

If the button is pressed for half a second:
Beep starts upon button press (a 1-second beep).
Halfway that beep, the button is released, and another 1-second beep should sound, but it's beeping already.
So beep for another full second, so 1 1/2 seconds total? Or wait for the first 1-second beep to complete, then play another 1-second beep for 2 seconds total?
Of course if the OP can somehow guarantee the user will always press the button for longer than the beep lasts, no problem. However as the user is a human, behaviour can never be guaranteed.

wvmarle:
Of course if the OP can somehow guarantee the user will always press the button for longer than the beep lasts, no problem. However as the user is a human, behaviour can never be guaranteed.

Which is why I asked in #10 yesterday:

meltDown:

  • Can the beep’s programmed length be longer than the time the button is held, and if so, what should happen?

Hi and thank you everybody for your concern,

Answering some questions:

  • The beep must me clear but short, I don't need a minimum time, I just need it to be short but with a clear and intense sound, short enought that if I push and release quite fast I can distinguish the sound.

  • The battery is 3V and the beeper works perfectly with the same charge

Thanks again

Time to start experimenting.
How long does your beep need to be for a "clear and intense sound"?
How fast can you press and release the button? Is that faster than the minimum time you just determined for the beep itself?

Hi wvmarle,

The beep needs 0.1 seconds of output to be a clear sound and the press and realease wouldn't be faster than that