Playing a simple tune using a simple buzzer (?!)

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
In this very moment the AVR board has a simple buzzer that plays a simple sound (beep @ 2.3kHz) using a timer interrupt to generate a rectangular signal on an output pin.
Well... the problem is that the client is not very satisfied with it: he said that a simple beep is not enough; he wants the AVR to play a short tune/melody, but using the existing hardware (i.e. the simple buzzer).
So, I need your help. Anyone knows how can I do it?
Thx in advance.

Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The AVR Butterfly (ahhh... the AVR Butterfly... ) uses a piezo element ( a 'buzzer') to play some tunes. The source code and the schematic can show you how its done. You can get the code on the Atmel website of the WinAVR port at http://www.siwawi.arubi.uni-kl.d....

Good Luck,
Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow, it’s exactly what I was looking for!
Thx Smiley.

Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

i am using avr butterfly in a project and can't find any code to play a tune using avr butterfly on mentioned link by smileymicros.

please elaborate.

thnx,
mandar

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go to the Atmel web site, [url=http://www.atmel.com/] Here [/url]

Under the ATMEL name in the upper left corner is a search box, (white box, against a white background, kind of hard to see on many monitors...)

Enter Butterfly and you will get 96 links to Butterfly related documents.

JC

How about that, a CAPTCHA for linking to the Atmel home page.

What a great system for a "High Tech" company to be using...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, first set up a timer interrupt for about 1/10th of a second. Then set up a second timer that puts out a square wave of audio frequency. Next have two software tables: the first table has the frequency of the note. This is the value that gets put into the timer count that sets the frequency. The second table has the number of 1/10th second intervals that the current note is being sounded.
With about a few years of studying data sheets and experimenting, you can get it all to run in the background and have your main demo program running as well in the foreground.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By the way, Mandar, you can start a new Thread!

You don't have to tack on to a 9 year old one.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I published an example tune[url]https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=116502...

Sorry, I just use my own "portab_mcu.h".
It enables me to use any of five different C compilers.

All you need is the GCC specific stuff:


#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <util/delay.h>

#define SEI() asm volatile("sei\n")

Note that you should put F_CPU=8000000 in your AS6 Project symbols.

I am sure that there must be several examples of sound for the Butterfly or Xmega Xplained boards.

Some 'piezos' will make a sound with d.c. and others need an a.c. voltage. You only get squarewaves so the sound is fairly rough.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:
By the way, Mandar, you can start a new Thread!

You don't have to tack on to a 9 year old one.

JC

He did what we always tell noobs to do: Use search.

The largest known prime number: 282589933-1

It's easy to stop breaking the 10th commandment! Break the 8th instead.