Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.
0

beep
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

beep

by LLavigne on Thu May 08, 2008 4:54 pm

How would I get the arduino to emit a simple beep ?
What component do I need?

Thanks.
_____________
www.previs.org
LLavigne
 
Posts: 6
Joined: Thu May 08, 2008 4:52 pm

by Volt Dropper on Fri May 09, 2008 1:19 am

Get a Piezo and beat on it with a PWM stick.
Volt Dropper
 
Posts: 30
Joined: Thu Apr 24, 2008 12:58 am

by Silver on Fri May 09, 2008 2:34 am

Get a simple Piezo buzzer from Radio Shack (Catalog #: 273-059). This small buzzer is about the size of four quarters stacked together.

The buzzer has two wires. Connect the black to ground and supply +5v to the red wire with any digital output. This will give you a beep for as long as the output pin is high.

You can also get different sounds by pulsing the +5v using Pulse Width Modulation (PWM) as Volt Dropper suggests.

Hope this helps,

Silver
Silver
 
Posts: 12
Joined: Mon Apr 21, 2008 1:39 am

by westfw on Fri May 09, 2008 4:10 am

I can think of four basic ways.

1) Get a "beeper" that has built-in electronics that make it beep. Checking current consumption, use an Arduino output pin to give it power, either directly or via one of the documented techniques for driving higher powered loads.

2) Use a simple external circuit that creates a beep frequency (say, using a 555 timer), and use an arduino pin to enable it (which is slightly different than powering it.)

3) Connect a speaker or piezo to an arduino pin with a suitable current-limiting resistor. Use software to toggle the pin at an audio frequency. The code looks just like the led blink example, but you cut the delays by a factor of 1000 or so (perhaps by replacing "delay" with "delayMicroseconds" ?)

4) with hardware as in (3), use one of the internal timers to make the pin toggle "automatically" without software intervention. It MIGHT work out that you can get a suitable tone by using the "analogOut" function with an intermediate value (50% for a square wave), but the PWM frequency used isn't documented, which means it might not be appropriate.

There are more complicated ways too. With suitable effort, you can get a "beep" that sounds like a polyphonic organ piece. (I recall hearing lesser micros play Bach in 4-part harmony. Or was it Beethoven? Too long ago!)

westfw
 
Posts: 1645
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

by adafruit on Fri May 09, 2008 11:44 am

you dont even really need PWM
just tun the pin high and low with a delayMicroseconds() in between
http://www.ladyada.net/make/eshield/popcheck.pde has an example

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by mtbf0 on Fri May 09, 2008 11:43 pm

westfw wrote:4) with hardware as in (3), use one of the internal timers to make the pin toggle "automatically" without software intervention. It MIGHT work out that you can get a suitable tone by using the "analogOut" function with an intermediate value (50% for a square wave), but the PWM frequency used isn't documented, which means it might not be appropriate.


488.28Hz.

that's 16000000 / 64 / 256 / 2. which is to say a 16MHz clock divided by a prescaler of 64 divided by 8 bits of clock resolution, (256), divided by double sloped operation.
User avatar
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am
Location: oakland ca

Arduino ChipTune

by Harvie on Wed Jun 11, 2008 8:07 am

Checkout my simple "chiptune" projects:
http://blog.harvie.cz/index.php?catid=18&blogid=1

Playing melody for old cellphone
and second one
Arduino Drum Sequencer
Harvie
 
Posts: 3
Joined: Tue Jun 10, 2008 4:43 pm

Please be positive and constructive with your questions and comments.