//NOTES
//3rd OCTAVE

//NATURALS
#define cTH 130.81
#define dTH 146.83
#define eTH 164.81
#define fTH 174.61
#define gTH 196
#define aTH 220
#define bTH 246.94

//SHARPS OR FLATS
#define csTH 138.59
#define dsTH 155.56
#define fsTH 185
#define gsTH 207.65
#define asTH 233.08

//4TH OCTAVE

//NATURALS
#define c 261.63
#define d 293.66
#define e 329.63
#define f 349.23
#define g 392
#define a 440
#define b 493.88

//SHARPS OR FLATS
#define cs 277.18
#define ds 311.13
#define fs 369.99
#define gs 415.30
#define as 466.16
//No Sound
#define NT  0

//END
int button = 2;
int buzzer = 23;

//ARRAYS

//Song One
int cO  [] = {gTH,c,c ,d ,c ,bTH,aTH,aTH,aTH,d,d,e ,d ,c ,bTH,gTH,gTH,e,e ,f ,e ,d ,c,aTH,NT,aTH,gTH,aTH,d,bTH,c,NT,gTH,c,c,c,bTH,bTH,c,bTH,aTH,gTH,gTH,e,e,d,c ,d ,g ,gTH,gTH,gTH,aTH,d,bTH,c};
int dO  [] = {4  ,4,12,12,12,12 ,4  ,4  ,4  ,4,8,12,12,12,4  ,4  ,4  ,4,12,12,12,12,4,4  ,32,12 ,4  ,4  ,4,4  ,2,8 ,2  ,4,4,4,2  ,4  ,4,4  ,4  ,2  ,4  ,4,4,8,12,12,4 ,4  ,12 ,12 ,4  ,4,4  ,4};

void setup() {
  for(int i = 0 ; i <= 24 ; i++)
  {
    pinMode(i , OUTPUT);
  }

}

void loop() 
{
songO();
ledOn();
delay(200);
ledOff();
delay(100);
blink1();
ledOff();

delay(10000);
}

void ledOn()
{
   for(int i = 0 ; i <= 24 ; i++)
  {
    digitalWrite(i , 1);
  }
}
void ledOff()
{
   for(int i = 0 ; i <= 24 ; i++)
  {
    digitalWrite(i , 0);
  }
}
void blink1()
{
    for(int i = 24 ; i >= 0 ; i--)
    {
      for (int j = 0 ; j <= i ;j++)
      {
        digitalWrite(j,1);
        delay(50);

          if (j != i)
          { 
            digitalWrite(j,0);
            delay(50);
          }
      }
            digitalWrite(i,1);
            delay(50);
    }
    for (int x = 0 ; x <= 24; x++)
      {
        digitalWrite(x,0);
        delay(50);
      }
      
}
void sound(int FREQ, int DURA)
{
  //You can Prolly add lights here (Array)
  tone(buzzer,FREQ);
  ledOn();
  delay(DURA);
  //You can Prolly add lights here (Array)
  noTone(buzzer);
  ledOff();
  delay(100);

}

//We Wish You A Merry Christmas
void songO()
{
for(int s = 0 ; s < 56 ; s++)
    {
      int nD = 1000 / dO[s]; //note Duration
      sound(cO[s], nD);

      int pBN = nD * 0.10; // pause Between Notes
      delay(pBN);
    }
}