Arduino Forum

Using Arduino => Audio => Topic started by: dehlen on Dec 11, 2012, 09:47 pm

Title: Piezo Buzzer - Win and Fail Sound
Post by: dehlen on Dec 11, 2012, 09:47 pm
Hey, i am searching for two sound examples for my piezo buzzer.
Currently i am using the piezo with the example from arduino
Code: [Select]

int melody[] = {
  262, 196,196, 220, 196,0, 247, 262};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4,4,4,4,4 };

for (int thisNote = 0; thisNote < 8; thisNote++) {
    int noteDuration = 1000/noteDurations[thisNote];
    tone(12, melody[thisNote],noteDuration);
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    noTone(12);
    }


But i am searching for a sound that underlines whether the user won or lost. But i can't find any examples for arduino/piezo sounds. So maybe you have some hints for me where i can find sounds like that for my arduino, or maybe you composed sounds like that by yourself :) ?!

Thanks
Title: Re: Piezo Buzzer - Win and Fail Sound
Post by: DuaneB on Dec 12, 2012, 02:59 pm
Hi,

I use two low notes - duh, duuhh to indicate fail and two fast arpeggios of higher notes for winning, you can hear them here, its not going to win any grammies, but you know whether you got a good lap or not.

http://www.youtube.com/watch?v=0_IP14gFKcI&feature=plcp (http://www.youtube.com/watch?v=0_IP14gFKcI&feature=plcp)

Duane B

rcarduino.blogspot.com (http://rcarduino.blogspot.com)
Title: Re: Piezo Buzzer - Win and Fail Sound
Post by: dehlen on Dec 12, 2012, 03:04 pm
Hey, first of all great project ! I like the sounds very much. Do you think you could send me the melody and noteDurations array for these two sounds ?
Title: Re: Piezo Buzzer - Win and Fail Sound
Post by: DuaneB on Dec 12, 2012, 03:09 pm
Its inline in the code like so, converting to an array would be better but I was experimenting with tunes this way -

Build your own lap timer here -

http://rcarduino.blogspot.com/2012/07/lap-timer-build-along-part-one.html (http://rcarduino.blogspot.com/2012/07/lap-timer-build-along-part-one.html)

Code: [Select]

if(lapTime == bestLapTime)
      {
        for(uint8_t nLoop = 0;nLoop < 2;nLoop ++)
        {
          tone(sAudioPin,NOTE_A5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_B5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_C5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_B5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_C5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_D5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_C5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_D5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_E5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_D5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_E5);
          delay(NOTE_SUSTAIN);
          tone(sAudioPin,NOTE_E5);
          delay(NOTE_SUSTAIN);
        }
        noTone(sAudioPin);
      }
      else
      {
          tone(sAudioPin,NOTE_G4);
          delay(250);
          tone(sAudioPin,NOTE_C4);
          delay(500);
          noTone(sAudioPin);
      }
Title: Re: Piezo Buzzer - Win and Fail Sound
Post by: dehlen on Dec 12, 2012, 03:30 pm
thanks a lot :)
Title: Re: Piezo Buzzer - Win and Fail Sound
Post by: DuaneB on Dec 12, 2012, 03:52 pm
If you Piezo still sounds a bit underwhelming you can try using a simple amplifier and a speaker for better quality sound -

http://rcarduino.blogspot.com/2012/08/adding-audio-to-arduino-projects.html (http://rcarduino.blogspot.com/2012/08/adding-audio-to-arduino-projects.html)

Duane B

rcarduino.blogspot.com (http://rcarduino.blogspot.com)