generate sound like alarm clock! with mega8

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

hi
i want to generate sound like alarm clock with mega8...please help me:)
i use codevision:)
thanks

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

AVR335

(code is IAR but it's the concept that you should be able to port ot CV - that is using PWM to recreate audio from PCM samples)

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

i write this program for warning sound but i do not know how can i generate sound like ALarm clock!:(

#include
#include
void main(void)
{
unsigned int f,t;
DDRA=0x01;
while (1)
{
for(f=200;f;f--)

{

PORTA.0=~PORTA.0;

for(t=20+f;t;t--)

delay_us(10);

}

};

}

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

So have you read application note AVR335 yet? Which bit about recreating sampled sounds from an AVR in it did you not understand?

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

Do you mean a CONSTANT sound like a moron who keeps the finger pressed on the doorbell or a beeping sound that's ON-OFF-ON-...etc ? If the on-off sound, then you just need a PWM at a pleasant ( or NOT ) freq. ( trial and error by listening to how it sounds ) to give you the beep tone you want.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

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

clawson wrote:
So have you read application note AVR335 yet? Which bit about recreating sampled sounds from an AVR in it did you not understand?

i read avr335 but i can not understand!:(

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

indianajones11 wrote:
Do you mean a CONSTANT sound like a moron who keeps the finger pressed on the doorbell or a beeping sound that's ON-OFF-ON-...etc ? If the on-off sound, then you just need a PWM at a pleasant ( or NOT ) freq. ( trial and error by listening to how it sounds ) to give you the beep tone you want.

yes or like alarm clock in old clocks!
do you have sample code for that?:(
thanks

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

Quote:

i read avr335 but i can not understand!

then it is

EITHER some specific wordings in the document that you dont understand - if so then quote thoswe words here qand we'll try to explain.

OR the document as a whole - in which case it seems that you have ventured into a project that is too omplicated for your current level of knowledge. Maybe start with something a bit easier? What have you done with microcontrollers up to now?

And why is it that we suddenly see several threads here with people wanting to generate/playback sounds like alarm clocks, police sirens etc? Did some teacher at some uni hand out this as an assignment?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

OP wrote:
yes or like alarm clock in old clocks
Yes... to which case ? Old clocks... the little round things with metal bells ? You can generate ALOT of different tones using single freq. and duration ( don't need the A.N. for THAT ). YOU have to do a better job of describing what the sound should be like so we know whether you need the A.N. or just PWM .

My digital alarm is just a periodic beeping, nothing special. Is this a school pjt. ?

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

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

Well an old alarm clock has two slightly different sounding bells. The sound sequence shall be close to some frequency hopping between two corresponding values at a rate 10...20 Hz methinks.
Imho worth giving an exercise with freeware sound editor for such a trial.
Implementation shall be quite trivial afterward.