//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 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.2
//5TH NATURALS
#define cF 523.3
#define dF 587.4
#define eF 659.3
#define fF 698.5
#define gF 784
#define aF 880
#define bF 987.8
//SHARPS OR FLATS
#define csF 554.4
#define dsF 622.3
#define fsF 740
#define gsF 830.6
#define asF 932.3
//No Sound
#define NT 0
// LIGHTS
//END
int buzzer = 23;
//ARRAYS
//LIGHTS
//Song One
int songOne [] = {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 delayOne [] = {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};
int sizeofSong1 = 56;
//Song Two
int songTwo [] = {c,g,g,f,e,d,c,gTH,NT,gTH,d,NT,d,c,bTH,gTH,NT,gTH,a,a,g,f,e,d,NT,b,a,g,NT,g,f,e,NT,e,d,c};
int delayTwo [] = {4,8,8,4,4,4,4,2,16,12,4,16,4,8,8,4,16,4,8,8,4,4,8,8,8,12,8,16,12,12,8,16,12,12,12,2};
int sizeofSong2 = 36;
//Song Three
int songThree [] = {g,fs,e,d,c,bTH,aTH,gTH,NT,d,e,NT,e,fs,NT,fs,g,NT,g,g,fs,e,d,d,c,bTH,g,g,fs,e,d,d,c,bTH,NT,bTH,bTH,bTH,c,d,bTH,aTH,aTH,aTH,bTH,c,NT,aTH,gTH,g,e,d,c,bTH,c,bTH,aTH,gTH};
int delayThree [] = {4,4,8,8,8,8,4,4,16,8,4,16,8,4,16,8,2,16,12,12,12,12,12,4,12,12,12,12,12,12,12,4,12,12,16,8,8,8,4,4,12,8,8,8,4,4,16,12,12,4,12,12,16,4,12,4,4,4};
int sizeofSong3 = 58;
void setup()
{
for(int i = 0 ; i <= 23 ; i++)
{
pinMode(i , OUTPUT);
}
}
void loop()
{
blink4();
ledOff();
delay(100);
blink6();
ledOn();
delay(100);
song1();
ledOff();
delay(100);
blink1();
ledOff();
delay(100);
blink2();
ledOff();
delay(100);
blink1();
delay(100);
ledOff();
delay(100);
song2();
ledOff();
delay(100);
blink3();
ledOff();
delay(100);
blink4();
ledOff();
delay(100);
song3();
ledOff();
delay(100);
blink7();
ledOff();
delay(100);
blink5();
ledOff();
delay(100);
blink7();
ledOff();
delay(100);
}
void song1()
{
for(int thisNote = 0 ; thisNote < sizeofSong1 ; thisNote++)
{
int noteDura = 1000/ delayOne[thisNote];
tone(buzzer, songOne[thisNote], noteDura);
if(thisNote == 0) ledOn();
if(thisNote == 1) ledOff();
if(thisNote == 2) SWest();
if(thisNote == 3) {ledOff();SEast();}
if(thisNote == 4) {ledOff();NEast();}
if(thisNote == 5) {ledOff();NWest();}
if(thisNote == 6) ledOff();
if(thisNote == 7) ledOn();
if(thisNote == 8) ledOff();
if(thisNote == 8) ledOn();
if(thisNote == 9) ledOff();
if(thisNote == 10) NWest();
if(thisNote == 11) {ledOff();NEast();}
if(thisNote == 12) {ledOff();SEast();}
if(thisNote == 13) {ledOff();SWest();}
if(thisNote == 14) ledOff();
if(thisNote == 15) ledOn();
if(thisNote == 16) ledOff();
if(thisNote == 17) Outer();
if(thisNote == 18) {ledOff();OMiddle();}
if(thisNote == 19) {ledOff();IMiddle();}
if(thisNote == 20) {ledOff();Inner();}
if(thisNote == 21) ledOff();
if(thisNote == 22) ledOn();
if(thisNote == 23) ledOff();
if(thisNote == 24) wantu();
if(thisNote == 25) trepor();
if(thisNote == 26) paibsix();
if(thisNote == 27) sebeneat();
if(thisNote == 28) {SWNE();}
if(thisNote == 28) {NWSE();}
if(thisNote == 29) ledOff();
if(thisNote == 30) ledOn();
if(thisNote == 31) ledOff();
if(thisNote == 32) Inner();
if(thisNote == 33) {ledOff();OMiddle();IMiddle();Outer();}
if(thisNote == 34) {ledOff();Inner();}
if(thisNote == 35) {ledOff();OMiddle();IMiddle();Outer();}
if(thisNote == 36) ledOn();
if(thisNote == 37) ledOff();
if(thisNote == 38) {SWest();paibsix();}
if(thisNote == 39) {ledOff();NEast();wantu();}
if(thisNote == 40) {ledOff();NWest();trepor();}
if(thisNote == 41) {ledOff();SEast();sebeneat();}
if(thisNote == 42) ledOff();
if(thisNote == 43) {trepor();sebeneat();OMiddle();}
if(thisNote == 44) {ledOff();wantu();paibsix();IMiddle();}
if(thisNote == 43) {ledOff();trepor();sebeneat();Outer();}
if(thisNote == 44) {ledOff();wantu();paibsix();OMiddle();}
if(thisNote == 45) ledOn();
if(thisNote == 46) ledOff();
if(thisNote == 47) ledOn();
if(thisNote == 48) {ledOff();Inner();}
if(thisNote == 49) {ledOff();OMiddle();IMiddle();Outer();}
if(thisNote == 50) ledOff();
if(thisNote == 51) ledOff();
if(thisNote == 52) ledOff();
if(thisNote == 53) ledOn();
if(thisNote == 54) ledOff();
if(thisNote == 55) {ledOn();delay(100);}
if(thisNote == 55) ledOff();
delay(noteDura);
int pauseBetweenNotes = noteDura * 0.30;
delay(pauseBetweenNotes);
noTone(buzzer);
}
}
void song2()
{
for(int thisNote = 0 ; thisNote < sizeofSong2 ; thisNote++)
{
int noteDura = 1000/ delayTwo[thisNote];
tone(buzzer, songTwo[thisNote], noteDura);
if(thisNote == 0) Inner();
if(thisNote == 1) SWest();
if(thisNote == 2) {SEast();delay(20);OSEast();}
if(thisNote == 3) {SEast();delay(20);NEast();delay(20);ONEast();}
if(thisNote == 4) {NEast();delay(20);NWest();delay(20);ONWest();}
if(thisNote == 5) ledOn();
if(thisNote == 6) ledOff();
if(thisNote == 7) ledOn();
if(thisNote == 8) ledOff();
if(thisNote == 9) SWNE();
if(thisNote == 10) {ledOff();NWSE();}
if(thisNote == 11) ledOn();
if(thisNote == 12) OSWest();
if(thisNote == 13) OSEast();
if(thisNote == 14) ONEast();
if(thisNote == 15) ONWest();
if(thisNote == 16) ledOff();
if(thisNote == 17) Outer();
if(thisNote == 18) {ledOff();OMiddle();}
if(thisNote == 19) {ledOff();IMiddle();}
if(thisNote == 19) {ledOff();Inner();}
if(thisNote == 20) {ledOff();IMiddle();}
if(thisNote == 21) {ledOff();OMiddle();}
if(thisNote == 22) {ledOff();Outer();}
if(thisNote == 23) ledOn();
if(thisNote == 24) ledOff();
if(thisNote == 25) ledOff();
if(thisNote == 26) {wantu();delay(20);trepor();}
if(thisNote == 27) {paibsix();delay(20);sebeneat();}
//28,29
if(thisNote == 30) IMiddle();
if(thisNote == 31) OMiddle();
if(thisNote == 32) Outer();
if(thisNote == 33) ledOff();
if(thisNote == 34) SWNE();
if(thisNote == 35) NWSE();
if(thisNote == 36) {ledOff();delay(20);ledOn();}
delay(noteDura);
int pauseBetweenNotes = noteDura * 0.30;
delay(pauseBetweenNotes);
noTone(buzzer);
}
ledOff();
}
void song3()
{
for(int thisNote = 0 ; thisNote < sizeofSong3 ; thisNote++)
{
int noteDura = 1000/ delayThree[thisNote];
tone(buzzer, songThree[thisNote], noteDura);
if(thisNote == 0) ledOn();
if(thisNote == 1) ledOff();
if(thisNote == 2) SWNE();
if(thisNote == 3) {NWSE();delay(50);ledOff();}
if(thisNote == 4) SWest();
if(thisNote == 5) SEast();
if(thisNote == 6) NWest();
if(thisNote == 7) NEast();
if(thisNote == 8) ledOff();
if(thisNote == 9) {wantu();paibsix();}
if(thisNote == 10) {trepor();sebeneat();}
if(thisNote == 12) IMiddle();
if(thisNote == 13) OMiddle();
if(thisNote == 14) ledOff();
if(thisNote == 15) Outer();
if(thisNote == 16) ledOn();
if(thisNote == 17) ledOff();
if(thisNote == 18) digitalWrite(0,1);
if(thisNote == 19) digitalWrite(1,1);
if(thisNote == 20) digitalWrite(2,1);
if(thisNote == 21) digitalWrite(3,1);
if(thisNote == 22) digitalWrite(4,1);
if(thisNote == 23) digitalWrite(5,1);
if(thisNote == 24) digitalWrite(6,1);
if(thisNote == 25) digitalWrite(7,1);
if(thisNote == 26) digitalWrite(8,1);
if(thisNote == 27) digitalWrite(11,1);
if(thisNote == 28) digitalWrite(10,1);
if(thisNote == 29) digitalWrite(9,1);
if(thisNote == 30) SWest();
if(thisNote == 31) NWest();
if(thisNote == 32) NEast();
if(thisNote == 33) SEast();
if(thisNote == 34) ledOff();
if(thisNote == 35) Inner();
if(thisNote == 36) OMiddle();
if(thisNote == 37) IMiddle();
if(thisNote == 38) Outer();
if(thisNote == 39) ledOff();
if(thisNote == 40) ledOn();
if(thisNote == 41) ledOff();
if(thisNote == 42) {wantu();paibsix();digitalWrite(8,1);digitalWrite(10,1);}
if(thisNote == 43) {ledOff();trepor();sebeneat();digitalWrite(9,1);digitalWrite(11,1);}
if(thisNote == 44) {ledOff();wantu();paibsix();digitalWrite(12,1);digitalWrite(14,1);}
if(thisNote == 43) {ledOff();trepor();sebeneat();digitalWrite(13,1);digitalWrite(15,1);}
if(thisNote == 44) Outer();
if(thisNote == 45) ledOff();
if(thisNote == 46) ledOn();
if(thisNote == 47) ledOff();
if(thisNote == 48) {wantu();paibsix();OMiddle();}
if(thisNote == 49) {trepor();sebeneat();IMiddle();Outer();delay(50);ledOff();}
if(thisNote == 50) ledOn();
if(thisNote == 51) ledOff();
if(thisNote == 52) {wantu();paibsix();IMiddle();}
if(thisNote == 53) {ledOff();trepor();sebeneat();Outer();}
if(thisNote == 54) {ledOff();wantu();paibsix();OMiddle();delay(50);ledOff();}
if(thisNote == 55) SWNE();
if(thisNote == 56) NWSE();
if(thisNote == 57) ledOff();
if(thisNote == 58) ledOn();
delay(noteDura);
int pauseBetweenNotes = noteDura * 0.30;
delay(pauseBetweenNotes);
noTone(buzzer);
}
ledOff();
}
void SWest()
{
digitalWrite(0,1);
digitalWrite(1,1);
digitalWrite(8,1);
digitalWrite(12,1);
digitalWrite(16,1);
}
void NWest()
{
digitalWrite(6,1);
digitalWrite(7,1);
digitalWrite(9,1);
digitalWrite(13,1);
digitalWrite(17,1);
}
void SEast()
{
digitalWrite(2,1);
digitalWrite(3,1);
digitalWrite(11,1);
digitalWrite(15,1);
digitalWrite(19,1);
}
void NEast()
{
digitalWrite(4,1);
digitalWrite(5,1);
digitalWrite(10,1);
digitalWrite(14,1);
digitalWrite(18,1);
}
void OSWest()
{
digitalWrite(0,0);
digitalWrite(1,0);
digitalWrite(8,0);
digitalWrite(12,0);
digitalWrite(16,0);
}
void ONWest()
{
digitalWrite(6,0);
digitalWrite(7,0);
digitalWrite(9,0);
digitalWrite(13,0);
digitalWrite(17,0);
}
void OSEast()
{
digitalWrite(2,0);
digitalWrite(3,0);
digitalWrite(11,0);
digitalWrite(15,0);
digitalWrite(19,0);
}
void ONEast()
{
digitalWrite(4,0);
digitalWrite(5,0);
digitalWrite(10,0);
digitalWrite(14,0);
digitalWrite(18,0);
}
void ISWest()
{
digitalWrite(8,1);
digitalWrite(12,1);
digitalWrite(16,1);
}
void INWest()
{
digitalWrite(9,1);
digitalWrite(13,1);
digitalWrite(17,1);
}
void ISEast()
{
digitalWrite(11,1);
digitalWrite(15,1);
digitalWrite(19,1);
}
void INEast()
{
digitalWrite(10,1);
digitalWrite(14,1);
digitalWrite(18,1);
}
void Inner()
{
for(int n = 0 ; n <= 7; n++)
{
digitalWrite(n,1);
}
}
void IMiddle()
{
for(int n = 8 ; n <= 11; n++)
{
digitalWrite(n,1);
}
}
void OMiddle()
{
for(int n = 12 ; n <= 15; n++)
{
digitalWrite(n,1);
}
}
void Outer()
{
for(int n = 16 ; n <= 19; n++)
{
digitalWrite(n,1);
}
}
void SWNE()
{
digitalWrite(6,1);
digitalWrite(7,1);
digitalWrite(9,1);
digitalWrite(13,1);
digitalWrite(17,1);
digitalWrite(2,1);
digitalWrite(3,1);
digitalWrite(11,1);
digitalWrite(15,1);
digitalWrite(19,1);
}
void NWSE()
{
digitalWrite(0,1);
digitalWrite(1,1);
digitalWrite(8,1);
digitalWrite(12,1);
digitalWrite(16,1);
digitalWrite(4,1);
digitalWrite(5,1);
digitalWrite(10,1);
digitalWrite(14,1);
digitalWrite(18,1);
}
void wantu()
{
digitalWrite(0,1);
digitalWrite(1,1);
}
void trepor()
{
digitalWrite(2,1);
digitalWrite(3,1);
}
void paibsix()
{
digitalWrite(4,1);
digitalWrite(5,1);
}
void sebeneat()
{
digitalWrite(6,1);
digitalWrite(7,1);
}
void ledOn()
{
for (int i = 0 ; i <= 19 ; i++)
{
digitalWrite(i,1);
}
}
void ledOff()
{
for (int i = 0 ; i <= 19 ; i++)
{
digitalWrite(i,0);
}
}
void blink1()
{
for(int i = 19 ; i >= 0 ; i--)
{
for (int j = 0 ; j <= i ;j++)
{
digitalWrite(j,1);
delay(30);
if (j != i)
{
digitalWrite(j,0);
delay(30);
}
}
digitalWrite(i,1);
delay(30);
}
for (int x = 0 ; x <= 19; x++)
{
digitalWrite(x,0);
delay(30);
}
}
void blink2()
{
for (int z = 1 ;z <= 15 ;z++)
{
if (z <= 3)
{
for (int i = 0 ; i <= 19 ; i++)
{
if (i == 0)
{
digitalWrite(0,1);
digitalWrite(1,1);
}
else if (i == 8) digitalWrite(i,1);
else if (i == 12) digitalWrite(i,1);
else if (i == 16) digitalWrite(i,1);
else {continue;}
delay(200);
if (z <= 2)
{
digitalWrite(1,0);
digitalWrite(0,0);
digitalWrite(8,0);
digitalWrite(12,0);
digitalWrite(16,0);
}
}
}
else if (z <= 6)
{
for (int i = 0 ; i <= 19 ; i++)
{
if (i == 7)
{
digitalWrite(2,1);
digitalWrite(3,1);
}
else if (i == 9) digitalWrite(i,1);
else if (i == 13) digitalWrite(i,1);
else if (i == 17) digitalWrite(i,1);
else {continue;}
delay(200);
if (z <= 5)
{
digitalWrite(2,0);
digitalWrite(3,0);
digitalWrite(9,0);
digitalWrite(13,0);
digitalWrite(17,0);
}
}
}
else if (z <= 9)
{
for (int i = 0 ; i <= 19 ; i++)
{
if (i == 5)
{
digitalWrite(4,1);
digitalWrite(5,1);
}
else if (i == 10) digitalWrite(i,1);
else if (i == 14) digitalWrite(i,1);
else if (i == 18) digitalWrite(i,1);
else {continue;}
delay(200);
if (z <= 8)
{
digitalWrite(5,0);
digitalWrite(4,0);
digitalWrite(10,0);
digitalWrite(14,0);
digitalWrite(18,0);
}
}
}
else if (z <= 12)
{
for (int i = 0 ; i <= 19 ; i++)
{
if (i == 3)
{
digitalWrite(6,1);
digitalWrite(7,1);
}
else if (i == 11) digitalWrite(i,1);
else if (i == 15) digitalWrite(i,1);
else if (i == 19) digitalWrite(i,1);
else {continue;}
delay(200);
if (z <= 11)
{
digitalWrite(6,0);
digitalWrite(7,0);
digitalWrite(11,0);
digitalWrite(15,0);
digitalWrite(19,0);
}
}
}
else if (z <= 15)
{
ledOn();
delay(200);
for (int j = 1 ; j <= 3 ;j++)
{
ledOn();
delay(200);
ledOff();
delay(200);
}
}
}
}
void blink3()
{
for (int z = 1 ; z <= 10 ; z++)
{
for (int i = 0 ; i <= 19 ; i++)
{
if (i == 1)
{
digitalWrite(0,1);
digitalWrite(1,1);
}
if (i == 8) digitalWrite(i,1);
else if (i == 12) digitalWrite(i,1);
else if (i == 16) digitalWrite(i,1);
if (i == 5)
{
digitalWrite(5,1);
digitalWrite(4,1);
}
else if (i == 10) digitalWrite(i,1);
else if (i == 14) digitalWrite(i,1);
else if (i == 18) digitalWrite(i,1);
else {continue;}
}
delay(200);
ledOff();
for (int i = 0 ; i <= 19 ; i++)
{
if (i == 0)
{
digitalWrite(6,1);
digitalWrite(7,1);
}
else if (i == 9) digitalWrite(i,1);
else if (i == 13) digitalWrite(i,1);
else if (i == 17) digitalWrite(i,1);
if (i == 3)
{
digitalWrite(3,1);
digitalWrite(2,1);
}
else if (i == 11) digitalWrite(i,1);
else if (i == 15) digitalWrite(i,1);
else if (i == 19) digitalWrite(i,1);
else {continue;}
}
delay(200);
ledOff();
}
}
void blink4()
{
for (int z = 1 ; z <= 3;z++)
{
for (int r = 1 ; r <= 8 ; r++)
{
if (r == 1)
{
for (int i = 0 ; i <= 7 ;i++)
{
digitalWrite(i,1);
}
delay(200);
}
if (r == 2)
{
for (int i = 8 ; i <= 11 ;i++)
{
digitalWrite(i,1);
}
delay(200);
}
if (r == 3)
{
for (int i = 12 ; i <= 15 ;i++)
{
digitalWrite(i,1);
}
delay(200);
}
if (r == 4)
{
for (int i = 16 ; i <= 19 ;i++)
{
digitalWrite(i,1);
}
delay(200);
ledOff();
}
if (r == 5)
{
for (int i = 16 ; i <= 19 ;i++)
{
digitalWrite(i,1);
}
delay(200);
}
if (r == 6)
{
for (int i = 12 ; i <= 15 ;i++)
{
digitalWrite(i,1);
}
delay(200);
}
if (r == 7)
{
for (int i = 8 ; i <= 11 ;i++)
{
digitalWrite(i,1);
}
delay(200);
}
if (r == 8)
{
for (int i = 0 ; i <= 7 ;i++)
{
digitalWrite(i,1);
}
delay(200);
ledOff();
}
}
}
}
void blink5()
{
for (int z = 1 ;z <= 12 ;z++)
{
for (int r = 1 ; r <= 2; r++)
{
if (r == 1)
{
for (int i = 0 ; i <= 19 ; i++)
{
if (i <= 7 && i >= 0)
{
if (i % 2 == 0 )
{
digitalWrite(i,1);
}
}
if (i <= 11 && i >= 8) digitalWrite(i,1);
else if (i <= 19 && i >= 16) digitalWrite(i,1);
}
}
delay(200);
ledOff();
if (r == 2)
{
for (int i = 0 ; i <= 19 ; i++)
{
if (i <= 7 && i >= 0)
{
if (i % 2 == 1 )
{
digitalWrite(i,1);
}
}
else if (i <= 15 && i >= 12) digitalWrite(i,1);
}
}
delay(200);
ledOff();
}
}
}
void blink6()
{
for (int z = 0 ;z <= 50 ;z++)
{
int randomNum = random(19);
digitalWrite(randomNum,1);
delay(100);
digitalWrite(randomNum,0);
}
}
void blink7()
{
for(int j = 1 ; j <= 20 ; j++)
{
int P = j - 1;
for(int i = 20 ; i > j ; i--)
{
int H = i - 1;
digitalWrite(H,1);
delay(30);
if (P != H)
{
digitalWrite(H,0);
delay(30);
}
}
digitalWrite(P,1);
delay(30);
}
for(int x = 20 ;x > 0 ;x--)
{
int y = x - 1;
digitalWrite(y,0);
delay(30);
}
}