sketch_21_buzzer_melodysailing

sketch_21_buzzer_melodysailing
  /*Plays a melody with Passive Buzzer, signal to Pin D4*/
  /*Include a list of tones, from pitches.h*/
  #include "pitches.h"       
                 
  /*We want to play this melody 
    Note durations: 4 = quarter note, 8 = eighth note, etc (set up an array)*/
  int melody[] =        {d1,e1,   g1,g1,h1,d2,   e2,e2,e2,d2,   d2,c2,c2,h1,   h1,c2,h1,   h1,a1,h1,a1,    a1,g1,e1,g1,   h1,a1,a1,a1,g1,    g1 };
  int noteDurations[] = { 8, 8,    4, 2, 8, 8,    4, 2, 8, 8,    4, 2, 8, 8,    2, 8, 8,    4, 2, 8, 8,     4, 2, 8, 8,    8, 8, 2, 8, 8,     2 };
  
  void setup() 
  {
     for (int thisNote = 0; thisNote < 31; thisNote++)     //the number must correspond to the array
     {
      int noteDuration = 3200 / noteDurations[thisNote];   //take one second (if 1000), divided by the note duration (e.g. 1/4 note)
      tone(4, melody[thisNote], noteDuration);
      int pauseBetweenNotes = noteDuration * 1.30;         //to distinguish the notes, set a minimum time between them.
      delay(pauseBetweenNotes);
      noTone(4);                                           // stop the tone playing
     }
  }
  
  void loop()
  {
     // no loop, the melody is played only once
  }
pitches.h
  /*Liste von Toenen*/
  #define C     65
  #define Cis   69
  #define D     73
  #define Dis   78
  #define E     82
  #define F     87
  #define Fis   93
  #define G     98
  #define Gis   104
  #define A     110
  #define Ais   117
  #define H     123
  #define c     131
  #define cis   139
  #define d     147
  #define dis   156
  #define e     165
  #define f     175
  #define fis   185
  #define g     196
  #define gis   208
  #define a     220
  #define ais   233
  #define h     247
  #define c1    262
  #define cis1  277
  #define d1     294
  #define dis1  311
  #define e1    330
  #define f1    349
  #define fis1  370
  #define g1    392
  #define gis1  415
  #define a1    440    //Kammerton a'
  #define ais1  466
  #define h1    494
  #define c2    523
  #define cis2  554
  #define d2    587
  #define dis2  622
  #define e2    659
  #define f2    698
  #define fis2  740
  #define g2    784
  #define gis2  831
  #define a2    880
  #define ais2  932
  #define h2    988
  #define c3   1047
  #define cis3 1109
  #define c3   1175
  #define dis3 1245
  #define e3   1319
  #define f3   1397
  #define fis3 1480
  #define g3   1568
  #define gis3 1661
  #define a3   1760
  #define ais3 1865
  #define h3   1976
  #define c4   2093