Forum / Guestbook




D.L.D. Sun 7 Jul 2019 at 12:23:28
Arduino make some NOISE! => Nokia rtttl Buzzer Tones / Tunes

-
Arduino make some NOISE! => Nokia rtttl Buzzer Tones / Tunes

11 Thousand tunes, make some noise ;-)
Passive Piezo Buzzer music for your egg timer alarm, etcetera

http://84.106.2.21:8888/forum/rtttl/RTTTL_Tunes/index.php?file=Doom.txt









  
// A fun sketch to demonstrate the use of the tone() function written by Brett Hagman.
// http://84.106.2.21:8888/forum/index.php?<wbr />action=view&id=300

// This plays RTTTL (RingTone Text Transfer Language) songs using the
// now built-in tone() command in Wiring and Arduino.
// Written by Brett Hagman
//  http://www.roguerobotics.com/

// To play the output on a small speaker (i.e. 8 Ohms or higher), simply use
// a 1K Ohm resistor from the output pin to the speaker, and connect the other
// side of the speaker to ground.

// You can get more RTTTL songs from
//  http://www.roguerobotics.com/
//  http://www.picaxe.com/RTTTL-Ringtones-for-Tune-Command/

const int tonePin = 8;  // D8 piezo passive buzzer
//const int tonePin = 13;  

#define OCTAVE_OFFSET 0

// These values can also be found as constants in the Tone library (Tone.h)
int notes[] = { 0,
                262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494,
                523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988,
                1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976,
                2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951
              };
char *song ="Wilhelmu:d=4,o=5,b=90:d,g,g,8a,8b,8c6,<wbr />8a,b,8a,8b,c6,b,8a,8g,a,2g,p,d,g,g,8a,8b<wbr />,8c6,8a,b,8a,8b,c6,b,8a,8g,a,2g,p,8b,8c6<wbr />,2d6,e6,2d6,c6,b,8a,8b,c6,b,a,g,2a,p,d,8<wbr />g,8f#,8g,8a,b,2a,g,f#,d,8e,8f#,g,g,f#,2g<wbr />";
//char *song0 = "GeorgeofthejungleTheme:d=4,o=6,b=127:f5<wbr />,p,p,c5,p,p,f5,p,f5,p,f5,a5,p,c,p,f5,p,f<wbr />5,p,g5,g5,p,a5,p,p,p,f5,f5,f5,f5,g5,g5,p<wbr />,f5,p,p,p,f";
//char *song1 = "OneMoreT:d=16,o=5,b=125:4e,4e,4e,4e,4e,<wbr />4e,8p,4d#.,4e,4e,4e,4e,4e,4e,8p,4d#.,4e,<wbr />4e,4e,4e,4e,4e,8p,4d#.,4f#,4f#,4f#,4f#,4<wbr />f#,4f#,8f#,4d#.,4e,4e,4e,4e,4e,4e,8p,4d#<wbr />.,4e,4e,4e,4e,4e,4e,8p,4d#.,1f#,2f#";
/<wbr />/char *song2 = "The Simpsons:d=4,o=5,b=160:c.6,e6,f#6,8a6,g.<wbr />6,e6,c6,8a,8f#,8f#,8f#,2g,8p,8p,8f#,8f#,<wbr />8f#,8g,a#.,8c6,8c6,8c6,c6";
//char *song3 = "Indiana:d=4,o=5,b=250:e,8p,8f,8g,8p,1c6<wbr />,8p.,d,8p,8e,1f,p.,g,8p,8a,8b,8p,1f6,p,a<wbr />,8p,8b,2c6,2d6,2e6,e,8p,8f,8g,8p,1c6,p,d<wbr />6,8p,8e6,1f.6,g,8p,8g,e.6,8p,d6,8p,8g,e.<wbr />6,8p,d6,8p,8g,f.6,8p,e6,8p,8d6,2c6";
//<wbr />char *song4 = "TakeOnMe:d=4,o=4,b=160:8f#5,8f#5,8f#5,8<wbr />d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g#5,8g#5,<wbr />8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8p,8f#5,8<wbr />p,8f#5,8p,8f#5,8e5,8e5,8f#5,8e5,8f#5,8f#<wbr />5,8f#5,8d5,8p,8b,8p,8e5,8p,8e5,8p,8e5,8g<wbr />#5,8g#5,8a5,8b5,8a5,8a5,8a5,8e5,8p,8d5,8<wbr />p,8f#5,8p,8f#5,8p,8f#5,8e5,8e5";
//char *song5 = "Entertainer:d=4,o=5,b=140:8d,8d#,8e,c6,<wbr />8e,c6,8e,2c.6,8c6,8d6,8d#6,8e6,8c6,8d6,e<wbr />6,8b,d6,2c6,p,8d,8d#,8e,c6,8e,c6,8e,2c.6<wbr />,8p,8a,8g,8f#,8a,8c6,e6,8d6,8c6,8a,2d6";<wbr />
//char *song6 = "Muppets:d=4,o=5,b=250:c6,c6,a,b,8a,b,g,<wbr />p,c6,c6,a,8b,8a,8p,g.,p,e,e,g,f,8e,f,8c6<wbr />,8c,8d,e,8e,8e,8p,8e,g,2p,c6,c6,a,b,8a,b<wbr />,g,p,c6,c6,a,8b,a,g.,p,e,e,g,f,8e,f,8c6,<wbr />8c,8d,e,8e,d,8d,c";
//char *song7 = "Xfiles:d=4,o=5,b=125:e,b,a,b,d6,2b.,1p,<wbr />e,b,a,b,e6,2b.,1p,g6,f#6,e6,d6,e6,2b.,1p<wbr />,g6,f#6,e6,d6,f#6,2b.,1p,e,b,a,b,d6,2b.,<wbr />1p,e,b,a,b,e6,2b.,1p,e6,2b.";
//char *song8 = "Looney:d=4,o=5,b=140:32p,c6,8f6,8e6,8d6<wbr />,8c6,a.,8c6,8f6,8e6,8d6,8d#6,e.6,8e6,8e6<wbr />,8c6,8d6,8c6,8e6,8c6,8d6,8a,8c6,8g,8a#,8<wbr />a,8f";
//char *song9 = "20thCenFox:d=16,o=5,b=140:b,8p,b,b,2b,p<wbr />,c6,32p,b,32p,c6,32p,b,32p,c6,32p,b,8p,b<wbr />,b,b,32p,b,32p,b,32p,b,32p,b,32p,b,32p,b<wbr />,32p,g#,32p,a,32p,b,8p,b,b,2b,4p,8e,8g#,<wbr />8b,1c#6,8f#,8a,8c#6,1e6,8a,8c#6,8e6,1e6,<wbr />8b,8g#,8a,2b";
//char *song10 = "Bond:d=4,o=5,b=80:32p,16c#6,32d#6,32d#6<wbr />,16d#6,8d#6,16c#6,16c#6,16c#6,16c#6,32e6<wbr />,32e6,16e6,8e6,16d#6,16d#6,16d#6,16c#6,3<wbr />2d#6,32d#6,16d#6,8d#6,16c#6,16c#6,16c#6,<wbr />16c#6,32e6,32e6,16e6,8e6,16d#6,16d6,16c#<wbr />6,16c#7,c.7,16g#6,16f#6,g#.6";
//char *song11 = "MASH:d=8,o=5,b=140:4a,4g,f#,g,p,f#,p,g,<wbr />p,f#,p,2e.,p,f#,e,4f#,e,f#,p,e,p,4d.,p,f<wbr />#,4e,d,e,p,d,p,e,p,d,p,2c#.,p,d,c#,4d,c#<wbr />,d,p,e,p,4f#,p,a,p,4b,a,b,p,a,p,b,p,2a.,<wbr />4p,a,b,a,4b,a,b,p,2a.,a,4f#,a,b,p,d6,p,4<wbr />e.6,d6,b,p,a,p,2b";
//char *song12 = "StarWars:d=4,o=5,b=45:32p,32f#,32f#,32f<wbr />#,8b.,8f#.6,32e6,32d#6,32c#6,8b.6,16f#.6<wbr />,32e6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6<wbr />,32e6,8c#.6,32f#,32f#,32f#,8b.,8f#.6,32e<wbr />6,32d#6,32c#6,8b.6,16f#.6,32e6,32d#6,32c<wbr />#6,8b.6,16f#.6,32e6,32d#6,32e6,8c#6";
/<wbr />/char *song13 = "GoodBad:d=4,o=5,b=56:32p,32a#,32d#6,32a<wbr />#,32d#6,8a#.,16f#.,16g#.,d#,32a#,32d#6,3<wbr />2a#,32d#6,8a#.,16f#.,16g#.,c#6,32a#,32d#<wbr />6,32a#,32d#6,8a#.,16f#.,32f.,32d#.,c#,32<wbr />a#,32d#6,32a#,32d#6,8a#.,16g#.,d#";
//c<wbr />har *song14 = "TopGun:d=4,o=4,b=31:32p,16c#,16g#,16g#,<wbr />32f#,32f,32f#,32f,16d#,16d#,32c#,32d#,16<wbr />f,32d#,32f,16f#,32f,32c#,16f,d#,16c#,16g<wbr />#,16g#,32f#,32f,32f#,32f,16d#,16d#,32c#,<wbr />32d#,16f,32d#,32f,16f#,32f,32c#,g#";
//<wbr />char *song15 = "A-Team:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g<wbr />#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p<wbr />,c#.6,16c6,16a#,g#.,2a#";
//char *song16 = "Flinstones:d=4,o=5,b=40:32p,16f6,16a#,1<wbr />6a#6,32g6,16f6,16a#.,16f6,32d#6,32d6,32d<wbr />6,32d#6,32f6,16a#,16c6,d6,16f6,16a#.,16a<wbr />#6,32g6,16f6,16a#.,32f6,32f6,32d#6,32d6,<wbr />32d6,32d#6,32f6,16a#,16c6,a#,16a6,16d.6,<wbr />16a#6,32a6,32a6,32g6,32f#6,32a6,8g6,16g6<wbr />,16c.6,32a6,32a6,32g6,32g6,32f6,32e6,32g<wbr />6,8f6,16f6,16a#.,16a#6,32g6,16f6,16a#.,1<wbr />6f6,32d#6,32d6,32d6,32d#6,32f6,16a#,16c.<wbr />6,32d6,32d#6,32f6,16a#,16c.6,32d6,32d#6,<wbr />32f6,16a#6,16c7,8a#.6";
//char *song17 = "Jeopardy:d=4,o=6,b=125:c,f,c,f5,c,f,2c,<wbr />c,f,c,f,a.,8g,8f,8e,8d,8c#,c,f,c,f5,c,f,<wbr />2c,f.,8d,c,a#5,a5,g5,f5,p,d#,g#,d#,g#5,d<wbr />#,g#,2d#,d#,g#,d#,g#,c.7,8a#,8g#,8g,8f,8<wbr />e,d#,g#,d#,g#5,d#,g#,2d#,g#.,8f,d#,c#,c,<wbr />p,a#5,p,g#.5,d#,g#";
//char *song18 = "Gadget:d=16,o=5,b=50:32d#,32f,32f#,32g#<wbr />,a#,f#,a,f,g#,f#,32d#,32f,32f#,32g#,a#,d<wbr />#6,4d6,32d#,32f,32f#,32g#,a#,f#,a,f,g#,f<wbr />#,8d#";
//char *song19 = "Smurfs:d=32,o=5,b=200:4c#6,16p,4f#6,p,1<wbr />6c#6,p,8d#6,p,8b,p,4g#,16p,4c#6,p,16a#,p<wbr />,8f#,p,8a#,p,4g#,4p,g#,p,a#,p,b,p,c6,p,4<wbr />c#6,16p,4f#6,p,16c#6,p,8d#6,p,8b,p,4g#,1<wbr />6p,4c#6,p,16a#,p,8b,p,8f,p,4f#";
//char *song20 = "MahnaMahna:d=16,o=6,b=125:c#,c.,b5,8a#.<wbr />5,8f.,4g#,a#,g.,4d#,8p,c#,c.,b5,8a#.5,8f<wbr />.,g#.,8a#.,4g,8p,c#,c.,b5,8a#.5,8f.,4g#,<wbr />f,g.,8d#.,f,g.,8d#.,f,8g,8d#.,f,8g,d#,8c<wbr />,a#5,8d#.,8d#.,4d#,8d#.";
//char *song21 = "LeisureSuit:d=16,o=6,b=56:f.5,f#.5,g.5,<wbr />g#5,32a#5,f5,g#.5,a#.5,32f5,g#5,32a#5,g#<wbr />5,8c#.,a#5,32c#,a5,a#.5,c#.,32a5,a#5,32c<wbr />#,d#,8e,c#.,f.,f.,f.,f.,f,32e,d#,8d,a#.5<wbr />,e,32f,e,32f,c#,d#.,c#";
//char *song22 = "DangerMo:d=4,o=5,b=355:a.,8g,a,8a,p,8a4<wbr />,8p,d,p,a.,8g,a,8a,p,8a4,8p,d,p,a,a,a#,a<wbr />#,a#,a#,a#,a#,a#,c6,2a,p,8a4,8p,d,p,a.,8<wbr />g,a,8a,p,8a4,8p,d,p,a.,8g,a,8a,p,8a4,8p,<wbr />d,p,a,a,a#,a#,a#,a#,a#,a#,a#,c6,2d6,p,8a<wbr />4,8p,d,p,a.,8a,2a#.,8a#4,8p,d#,2p,a#,2a#<wbr />,2f#,2d#,a#.,8a#,2b.,8b4,8p,e,2p,b,2b,2g<wbr />,2e,b.,8d6,1e.6,e6,8e6,8e";
//char *song23 = "MissionImp:d=16,o=6,b=95:32d,32d#,32d,3<wbr />2d#,32d,32d#,32d,32d#,32d,32d,32d#,32e,3<wbr />2f,32f#,32g,g,8p,g,8p,a#,p,c7,p,g,8p,g,8<wbr />p,f,p,f#,p,g,8p,g,8p,a#,p,c7,p,g,8p,g,8p<wbr />,f,p,f#,p,a#,g,2d,32p,a#,g,2c#,32p,a#,g,<wbr />2c,a#5,8c,2p,32p,a#5,g5,2f#,32p,a#5,g5,2<wbr />f,32p,a#5,g5,2e,d#,8d";
//char *song24  = "PinkPanther:d=4,o=5,b=160:8d#,8e,2p,8f#<wbr />,8g,2p,8d#,8e,16p,8f#,8g,16p,8c6,8b,16p,<wbr />8d#,8e,16p,8b,2a#,2p,16a,16g,16e,16d,2e"<wbr />;
//char *song25  = "2 Unlimited - No Limits:d=8,o=5,b=180:4e,4e,p,g,g,4e,4e,p<wbr />,g,g,e,4e,p,g,e,a,a,b,4b,4e,4e,p,g,g,4e,<wbr />4e,p,g,g,4e,4e,p,g,e,a,4a,4b,4b#";
//ch<wbr />ar *song26  = "Xfiles:d=4,o=5,b=125:e,b,a,b,d6,2b.,1p,<wbr />e,b,a,b,e6,2b.,1p,g6,f#6,e6,d6,e6,2b.,1p<wbr />,g6,f#6,e6,d6,f#6,2b.,1p,e,b,a,b,d6,2b.,<wbr />1p,e,b,a,b,e6,2b.,1p,e6,2b.";

void setup(void)
{
  Serial.begin(9600);
}

#define isdigit(n) (n >= '0' && n <= '9')

void play_rtttl(char *p)
{
  // Absolutely no error checking in here

  byte default_dur = 4;
  byte default_oct = 6;
  int bpm = 63;
  int num;
  long wholenote;
  long duration;
  byte note;
  byte scale;

  // format: d=N,o=N,b=NNN:
  // find the start (skip name, etc)

  while (*p != ':') p++;   // ignore name
  p++;                     // skip ':'

  // get default duration
  if (*p == 'd')
  {
    p++; p++;              // skip "d="
    num = 0;
    while (isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    if (num > 0) default_dur = num;
    p++;                   // skip comma
  }

  Serial.print("ddur: "); Serial.println(default_dur, 10);

  // get default octave
  if (*p == 'o')
  {
    p++; p++;              // skip "o="
    num = *p++ - '0';
    if (num >= 3 && num <= 7) default_oct = num;
    p++;                   // skip comma
  }

  Serial.print("doct: "); Serial.println(default_oct, 10);

  // get BPM
  if (*p == 'b')
  {
    p++; p++;              // skip "b="
    num = 0;
    while (isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }
    bpm = num;
    p++;                   // skip colon
  }

  Serial.print("bpm: "); Serial.println(bpm, 10);

  // BPM usually expresses the number of quarter notes per minute
  wholenote = (60 * 1000L / bpm) * 4;  // this is the time for whole note (in milliseconds)

  Serial.print("wn: "); Serial.println(wholenote, 10);


  // now begin note loop
  while (*p)
  {
    // first, get note duration, if available
    num = 0;
    while (isdigit(*p))
    {
      num = (num * 10) + (*p++ - '0');
    }

    if (num) duration = wholenote / num;
    else duration = wholenote / default_dur;  // we will need to check if we are a dotted note after

    // now get the note
    note = 0;

    switch (*p)
    {
      case 'c':
        note = 1;
        break;
      case 'd':
        note = 3;
        break;
      case 'e':
        note = 5;
        break;
      case 'f':
        note = 6;
        break;
      case 'g':
        note = 8;
        break;
      case 'a':
        note = 10;
        break;
      case 'b':
        note = 12;
        break;
      case 'p':
      default:
        note = 0;
    }
    p++;

    // now, get optional '#' sharp
    if (*p == '#')
    {
      note++;
      p++;
    }

    // now, get optional '.' dotted note
    if (*p == '.')
    {
      duration += duration / 2;
      p++;
    }

    // now, get scale
    if (isdigit(*p))
    {
      scale = *p - '0';
      p++;
    }
    else
    {
      scale = default_oct;
    }

    scale += OCTAVE_OFFSET;

    if (*p == ',')
      p++;       // skip comma for next note (or we may be at the end)

    // now play the note

    if (note)
    {
      Serial.print("Playing: ");
      Serial.print(scale, 10); Serial.print(' ');
      Serial.print(note, 10); Serial.print(" (");
      Serial.print(notes[(scale - 4) * 12 + note], 10);
      Serial.print(") ");
      Serial.println(duration, 10);
      tone(tonePin, notes[(scale - 4) * 12 + note]);
      delay(duration);
      noTone(tonePin);
    }
    else
    {
      Serial.print("Pausing: ");
      Serial.println(duration, 10);
      delay(duration);
    }
  }
}

void loop(void)
{
 play_rtttl(song);
 /*
//  play_rtttl(song1);
//  play_rtttl(song2);
//  play_rtttl(song3);
//  play_rtttl(song4);
//  play_rtttl(song5);
  play_rtttl(song6);
  play_rtttl(song7);
  play_rtttl(song8);
  play_rtttl(song9);
  play_rtttl(song10);
  play_rtttl(song11);
  play_rtttl(song12);
  play_rtttl(song13);
  play_rtttl(song14);
  play_rtttl(song15);
  play_rtttl(song16);
  play_rtttl(song17);
  play_rtttl(song17);
  play_rtttl(song19);
  play_rtttl(song20);
 // play_rtttl(song21);
 // play_rtttl(song22);
 // play_rtttl(song23);
 // play_rtttl(song24);
 // play_rtttl(song25);
 // play_rtttl(song26);

  Serial.println("Done.");
/
*/
// http://84.106.2.21:8888/forum/index.php?<wbr />action=view&id=300
}

  
  
  
  
  
  
  
  
  
  
  
  

GooseBumps Shivers loading a game with telex paper punch tape




End of Message, Thanks For Viewing! ☺
Tip: if your watching on your phone or tablet ⁝ add / save to homescreen and you get a nice icon its Free!
Tip: on your computer or laptop do not forget to bookmark this page its Free!
BookMark ShortCut Keys press ctrl+d on your keyboard




-

-

Reply to this Message







POLL / VOTE
Did you like this Page id=300 ?

NO:         YES:




   


Design a Bit like ForumOne 4.0 WayBack 1999 ©
Always Read the Small print?!



http://forum.luberth.com - - http://www.luberth.com/forum/

NO COOKIES !?

thanks for your support
Thank You!




Co2 FootPrint WebServer



                         My Cheap Chinese Friend Ali     
Copyright Luberth Dijkman 2018 ... 2019




GoodBye Galaxy!