Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Beep sound on push button

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Activity points
9,442
Guys,

Beep on atmega128
How can I generate "beep" sound on push button ?
Is there any simple way to use PWM for it ?
any links or informations will be appreciated

Thanks
 

I've sent triangle, square, and sine waves through speakers to generate noises. While square waves tend to be ugly, you can still get a noise out of it, although I'd say it's more of a "buzz" than a "beep".

Anyway, chances are your uC won't be able to supply enough current for the speaker to get any sort of volume out of it, so you probably will need to use a transistor. You can send the PWM signal to the base and throw the speaker as the load on the collector, for example. I found an example after a quick search here:
https://allaboutlearningandearning.blogspot.jp/2011/07/interfacing-of-buzzer-using.html

For the button, I'd have your interrupt handler start and stop the PWM. If you trigger your external interrupt to change on any logical change (after debouncing, of course) you can check your logic level in the interrupt vector to start PWM on a '1' and stop it on a '0'.

If you want a prettier sound, you could do a few things, most of which are a bit silly. If you have extra pins, you can probably find a DAC and output your DAC output to the base instead of the PWM, controlling the DAC within the interrupt as well. You can also shape your square wave into a sine wave with a few filters, especially if you only need one frequency. You can use RC filters, for example, or integrate your PWM square wave into a triangle wave and then use the diode breakpoint method to make a sinewave, but that's a lot of effort for a beep.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top