You are on page 1of 18

constintbuzzerPin=9//showswhichpinthewireconnectedtothebuzzerisin

constintsongLength1=10//#ofnotesinthesong
constintsongLength2=10//therearemultiplesongssoitshowsthelyricsfirstandthenthenotesthatgo
withthoselyrics
constintsongLength3=10
constintsongLength4=10
constintsongLength5=9
constintsongLength6=8
constintsongLength7=7
constintsongLength8=2
constintsongLength9=8
constintsongLength10=10
constintsongLength11=6
constintsongLength12=5
constintsongLength13=4
constintsongLength14=9
constintsongLength15=10
constintsongLength16=9
constintsongLength17=2
constintsongLength18=4
intdatapin=7//showswhichpinsthewiresforthelightsaregoinginto
intclockpin=6
intlatchpin=1
#include<LiquidCrystal.h>//includesalibrarysowecanprogramthelcdtosaythelyrics
LiquidCrystallcd(12,11,5,4,3,2)//showswhichpinsthelcdisconnectedto
bytedata=0
//showswhichnotesandhowlongtoplaythemforeachsonglyricsarenexttothemtoclarify
charnotes1[]="egCCCgbDCg"//Theseaweedisalwaysgreener
intbeats1[]={1,1,1,2,2,1,2,2,2,2}
charnotes2[]="cegggcdfe"//Insomebodyelse'slake
intbeats2[]={1,1,1,2,2,1,2,2,2,2}
charnotes3[]="egCCCgbDCg"//Youdreamaboutgoingupthere
intbeats3[]={1,1,1,2,2,1,2,2,2,2}
charnotes4[]="cegggcdfe"//Butthatisabigmistake
intbeats4[]={1,1,1,2,2,1,2,2,2,2}
charnotes5[]="aCCagCgC"//Justlookattheworldaroundyou
intbeats5[]={2,1,1,1,2,1,1,1,1}
charnotes6[]="DDDCEDC"//Righthereontheoceanfloor
intbeats6[]={2,1,2,2,1,2,2,3}
charnotes7[]="aCCagC"//Suchwonderfulthingssurround
intbeats7[]={2,1,2,2,1,2,2}
charnotes8[]="gC"//you
intbeats8[]={2,2}
charnotes9[]="DDDCEDC"//Whatmoreisyoulookin'for?
intbeats9[]={2,1,2,2,1,2,2,3}
charnotes10[]="EDCagEDCD"//UndertheseaUnderthesea
intbeats10[]={3,1,2,1,4,3,1,2,1,4}
charnotes11[]="EDCaf"//Darlingit'sbetter

intbeats11[]={3,1,2,1,2,2}
charnotes12[]="EDCag"//Downwhereit'swetter
intbeats12[]={1,2,1,2,2}
charnotes13[]="EDCE"//Takeitfromme
intbeats13[]={1,2,1,4}
charnotes14[]="EDCaCCaD"//Upontheshoretheyworkallday
intbeats14[]={3,1,2,1,2,1,2,1,2}
charnotes15[]="DCDEEDEDC"//Outinthesuntheyslaveaway
intbeats15[]={3,1,2,1,2,1,2,1,1,1}
charnotes16[]="EDCafEDC"//Whilewedevotin'fulltimeto
intbeats16[]={3,1,2,1,2,2,1,2,1}
charnotes17[]="ag"//floatin'
intbeats17[]={2,2}
charnotes18[]="EDCC"//Underthesea
intbeats18[]={1,2,1,4}
inttempo=160//changeshowfastorslowthesongsplay
voidsetup(){
//music
pinMode(buzzerPin,OUTPUT)//defineswhichpinthebuzzerisconnectedto
{
//light
pinMode(datapin,OUTPUT)//defineswhatthepinsdo
pinMode(clockpin,OUTPUT)
pinMode(latchpin,OUTPUT)
}

voidloop(){
//maincodehererunsrepeatedly

//song1
delay(750)//delayfor.75second
lcd.begin(16,2)//startthelettersat(16,2)
lcd.clear()//clearwhateverwastherebefore
lcd.print("Theseaweedis")//printthewords:theseaweedis
lcd.setCursor(0,1)//settheinvisiblecursortothesecondrow
lcd.print("alwaysgreener")//printthewords:alwaysgreener
inta,duration1//startsthesong

for(a=0a<songLength1a++)//stepthroughthesongarrays
{
duration1=beats1[a]*tempo//lengthofnote/restinms

if(notes1[a]=='')//ifaspaceisprinted
{
delay(duration1)//thenpauseforamoment
}

else//otherwise,playthenote
{
tone(buzzerPin,frequency1(notes1[a]),duration1)//tellsitwhichnotetoplay
delay(duration1)//waitfortonetofinish
}
delay(tempo/10)//howlongitplaysthenotefor
}
//song2
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Insomebody")
lcd.setCursor(0,1)
lcd.print("else'slake")

intb,duration2

for(b=0b<songLength2b++)//stepthroughthesongarrays
{
duration2=beats2[b]*tempo//lengthofnote/restinms

if(notes2[b]=='')//isthisarest?
{
delay(duration2)//thenpauseforamoment
}
else//otherwise,playthenote
{
tone(buzzerPin,frequency2(notes2[b]),duration2)
delay(duration2)//waitfortonetofinish
}
delay(tempo/10)
}
//song3
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Youdreamabout")
lcd.setCursor(0,1)
lcd.print("goingupthere")

intc,duration3

for(c=0c<songLength3c++)//stepthroughthesongarrays
{
duration3=beats3[c]*tempo//lengthofnote/restinms

if(notes3[c]=='')//isthisarest?
{
delay(duration3)//thenpauseforamoment

}
else//otherwise,playthenote
{
tone(buzzerPin,frequency3(notes3[c]),duration3)
delay(duration3)//waitfortonetofinish
}
delay(tempo/10)
}
//song4
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Butthatisa")
lcd.setCursor(0,1)
lcd.print("bigmistake")

intd,duration4

for(d=0d<songLength4d++)//stepthroughthesongarrays
{
duration4=beats4[d]*tempo//lengthofnote/restinms

if(notes4[d]=='')//isthisarest?
{
delay(duration4)//thenpauseforamoment
}
else//otherwise,playthenote
{
tone(buzzerPin,frequency4(notes4[d]),duration4)
delay(duration4)//waitfortonetofinish
}
delay(tempo/10)
}
//song5
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Justlookatthe")
lcd.setCursor(0,1)
lcd.print("worldaroundyou")

inte,duration5

for(e=0e<songLength5e++)//stepthroughthesongarrays
{
duration5=beats5[e]*tempo//lengthofnote/restinms

if(notes5[e]=='')//isthisarest?
{
delay(duration5)//thenpauseforamoment

}
else//otherwise,playthenote
{
tone(buzzerPin,frequency5(notes5[e]),duration5)
delay(duration5)//waitfortonetofinish
}
delay(tempo/10)
}
//song6
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Righthereon")
lcd.setCursor(0,1)
lcd.print("theoceanfloor")

intf,duration6

for(f=0f<songLength6f++)//stepthroughthesongarrays
{
duration6=beats6[f]*tempo//lengthofnote/restinms

if(notes6[f]=='')//isthisarest?
{
delay(duration6)//thenpauseforamoment
}
else//otherwise,playthenote
{
tone(buzzerPin,frequency6(notes6[f]),duration6)
delay(duration6)//waitfortonetofinish
}
delay(tempo/10)
}
//song7
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Suchwonderful")
lcd.setCursor(0,1)
lcd.print("thingssurround")

intg,duration7

for(g=0g<songLength7g++)//stepthroughthesongarrays
{
duration7=beats7[g]*tempo//lengthofnote/restinms

if(notes7[g]=='')//isthisarest?
{
delay(duration7)//thenpauseforamoment

}
else//otherwise,playthenote
{
tone(buzzerPin,frequency7(notes7[g]),duration7)
delay(duration7)//waitfortonetofinish
}
delay(tempo/10)
}
//song8
lcd.clear()
lcd.setCursor(0,0)
lcd.print("you")

inth,duration8

for(h=0h<songLength8h++)//stepthroughthesongarrays
{
duration8=beats8[h]*tempo//lengthofnote/restinms

if(notes8[h]=='')//isthisarest?
{
delay(duration8)//thenpauseforamoment
}
else//otherwise,playthenote
{
tone(buzzerPin,frequency8(notes8[h]),duration8)
delay(duration8)//waitfortonetofinish
}
delay(tempo/10)
}
//song9
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Whatmoreisyou")
lcd.setCursor(0,1)
lcd.print("lookin'for?")

inti,duration9

for(i=0i<songLength9i++)//stepthroughthesongarrays
{
duration9=beats9[i]*tempo//lengthofnote/restinms

if(notes9[i]=='')//isthisarest?
{
delay(duration9)//thenpauseforamoment
}
else//otherwise,playthenote

{
tone(buzzerPin,frequency9(notes9[i]),duration9)
delay(duration9)//waitfortonetofinish
}
delay(tempo/10)
}
//song10
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Underthesea")
lcd.setCursor(0,1)
lcd.print("Underthesea")

intj,duration10

for(j=0j<songLength10j++)//stepthroughthesongarrays
{
duration10=beats10[j]*tempo//lengthofnote/restinms

if(notes10[j]=='')//isthisarest?
{
delay(duration10)//thenpauseforamoment
}
else//otherwise,playthenote
{
tone(buzzerPin,frequency10(notes10[j]),duration10)
delay(duration10)//waitfortonetofinish
}
delay(tempo/10)
}
//song11
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Darlingit's")
lcd.setCursor(0,1)
lcd.print("better")

intk,duration11

for(k=0k<songLength11k++)//stepthroughthesongarrays
{
duration11=beats11[k]*tempo//lengthofnote/restinms

if(notes11[k]=='')//isthisarest?
{
delay(duration11)//thenpauseforamoment
}

else//otherwise,playthenote
{
tone(buzzerPin,frequency11(notes11[k]),duration11)
delay(duration11)//waitfortonetofinish
}
delay(tempo/10)
}
//song12
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Downwhere")
lcd.setCursor(0,1)
lcd.print("it'swetter")

intl,duration12

for(l=0l<songLength12l++)//stepthroughthesongarrays
{
duration12=beats12[l]*tempo//lengthofnote/restinms

if(notes12[l]=='')//isthisarest?
{
delay(duration12)//thenpauseforamoment
}
else//otherwise,playthenote
{
tone(buzzerPin,frequency12(notes12[l]),duration12)
delay(duration12)//waitfortonetofinish
}
delay(tempo/10)
}
//song13
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Takeitfromme")

intm,duration13

for(m=0m<songLength13m++)//stepthroughthesongarrays
{
duration13=beats13[m]*tempo//lengthofnote/restinms

if(notes13[m]=='')//isthisarest?
{
delay(duration13)//thenpauseforamoment
}
else//otherwise,playthenote

{
tone(buzzerPin,frequency13(notes13[m]),duration13)
delay(duration13)//waitfortonetofinish
}
delay(tempo/10)
}
//song14
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Upontheshore")
lcd.setCursor(0,1)
lcd.print("theyworkallday")

intn,duration14

for(n=0n<songLength14n++)//stepthroughthesongarrays
{
duration14=beats14[n]*tempo//lengthofnote/restinms

if(notes14[n]=='')//isthisarest?
{
delay(duration14)//thenpauseforamoment
}
else//otherwise,playthenote
{
tone(buzzerPin,frequency14(notes14[n]),duration14)
delay(duration14)//waitfortonetofinish
}
delay(tempo/10)
}
//song15
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Outinthesun")
lcd.setCursor(0,1)
lcd.print("theyslaveaway")

into,duration15

for(o=0o<songLength15o++)//stepthroughthesongarrays
{
duration15=beats15[o]*tempo//lengthofnote/restinms

if(notes15[o]=='')//isthisarest?
{
delay(duration15)//thenpauseforamoment
}
else//otherwise,playthenote

{
tone(buzzerPin,frequency15(notes15[o]),duration15)
delay(duration15)//waitfortonetofinish
}
delay(tempo/10)
}
//song16
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Whilewedevotin")
lcd.setCursor(0,1)
lcd.print("fulltimeto")

intp,duration16

for(p=0p<songLength16p++)//stepthroughthesongarrays
{
duration16=beats16[p]*tempo//lengthofnote/restinms

if(notes16[p]=='')//isthisarest?
{
delay(duration16)//thenpauseforamoment
}
else//otherwise,playthenote
{
tone(buzzerPin,frequency16(notes16[p]),duration16)
delay(duration16)//waitfortonetofinish
}
delay(tempo/10)
}
//song17
lcd.clear()
lcd.setCursor(0,0)
lcd.print("floatin'")

intq,duration17

for(q=0q<songLength17q++)//stepthroughthesongarrays
{
duration17=beats17[q]*tempo//lengthofnote/restinms

if(notes17[q]=='')//isthisarest?
{
delay(duration17)//thenpauseforamoment
}
else//otherwise,playthenote
{
tone(buzzerPin,frequency17(notes17[q]),duration17)

delay(duration17)//waitfortonetofinish
}
delay(tempo/10)
}
//song18
lcd.clear()
lcd.setCursor(0,0)
lcd.print("Underthesea")
delay(750)
lcd.clear()
intr,duration18

for(r=0r<songLength18r++)//stepthroughthesongarrays
{
duration18=beats18[r]*tempo//lengthofnote/restinms

if(notes18[r]=='')//isthisarest?
{
delay(duration18)//thenpauseforamoment
}
else//otherwise,playthenote
{
tone(buzzerPin,frequency18(notes18[r]),duration18)
delay(duration18)//waitfortonetofinish
}
delay(tempo/10)
}

//lights

pingPong()//lightslightupinabackandforthpattern

}
intfrequency1(charnote)//whatnotescanbeplayedforeachsong
{
inta//aisthefirstsong
constintnumNotes1=11//howmanynotesareabletobeplayed

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}//thenotesthatareabletobeplayed
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}//frequencyofnotesthat
areabletobeplayed
for(a=0a<numNotes1a++)//Thisfor()loopwillstepindexfrom0to7putting"++"afteravariable
meansaddonetoit
{
if(names[a]==note)//checkswhichnoteshouldbeplayed
{
return(frequencies[a])//playthenote
}

}
return(0)//gobackintomainloop
}
intfrequency2(charnote)
{
intb
constintnumNotes2=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(b=0b<numNotes2b++)
{
if(names[b]==note)

{
return(frequencies[b])
}
}
return(0)
}

intfrequency3(charnote)
{
intc
constintnumNotes3=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(c=0c<numNotes3c++)
{
if(names[c]==note)

{
return(frequencies[c])
}
}
return(0)
}

intfrequency4(charnote)
{
intd
constintnumNotes4=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(d=0d<numNotes4d++)
{
if(names[d]==note)

return(frequencies[d])
}
}
return(0)
}

intfrequency5(charnote)
{
inte
constintnumNotes5=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(e=0e<numNotes5e++)
{
if(names[e]==note)

{
return(frequencies[e])
}
}
return(0)
}

intfrequency6(charnote)
{
intf
constintnumNotes6=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(f=0f<numNotes6f++)
{
if(names[f]==note)

{
return(frequencies[f])
}
}
return(0)
}

intfrequency7(charnote)
{
intg
constintnumNotes7=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(g=0g<numNotes7g++)

{
if(names[g]==note)

{
return(frequencies[g])
}
}
return(0)
}

intfrequency8(charnote)
{
inth
constintnumNotes8=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(h=0h<numNotes8h++)
{
if(names[h]==note)

{
return(frequencies[h])
}
}
return(0)
}

intfrequency9(charnote)
{
inti
constintnumNotes9=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(i=0i<numNotes9i++)
{
if(names[i]==note)

{
return(frequencies[i])
}
}
return(0)
}

intfrequency10(charnote)
{
intj
constintnumNotes10=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(j=0j<numNotes10j++)
{
if(names[j]==note)

{
return(frequencies[j])
}
}
return(0)
}

intfrequency11(charnote)
{
intk
constintnumNotes11=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(k=0k<numNotes11k++)
{
if(names[k]==note)

{
return(frequencies[k])
}
}
return(0)
}

intfrequency12(charnote)
{
intl
constintnumNotes12=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(l=0l<numNotes12l++)
{
if(names[l]==note)

{
return(frequencies[l])
}
}
return(0)
}

intfrequency13(charnote)
{

intm
constintnumNotes13=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(m=0m<numNotes13m++)
{
if(names[m]==note)

{
return(frequencies[m])
}
}
return(0)
}

intfrequency14(charnote)
{
intn
constintnumNotes14=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(n=0n<numNotes14n++)
{
if(names[n]==note)

{
return(frequencies[n])
}
}
return(0)
}

intfrequency15(charnote)
{
into
constintnumNotes15=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(o=0o<numNotes15o++)
{
if(names[o]==note)

{
return(frequencies[o])
}
}
return(0)
}


intfrequency16(charnote)
{
intp
constintnumNotes16=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(p=0p<numNotes16p++)
{
if(names[p]==note)

{
return(frequencies[p])
}
}
return(0)
}

intfrequency17(charnote)
{
intq
constintnumNotes17=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(q=0q<numNotes17q++)
{
if(names[q]==note)

{
return(frequencies[q])
}
}
return(0)
}

intfrequency18(charnote)
{
intr
constintnumNotes18=11

charnames[]={'c','d','e','f','g','a','b','C','D','E','F','G'}
intfrequencies[]={131,147,165,175,196,220,247,262,294,330,349,392}
for(r=0r<numNotes18r++)
{
if(names[r]==note)

{
return(frequencies[r])
}

}
return(0)
}
//endofsound
//lightbelow

voidshiftWrite(intdesiredPin,booleandesiredState)//setstheicutoturnonLED
{
bitWrite(data,desiredPin,desiredState)
shiftOut(datapin,clockpin,MSBFIRST,data)
digitalWrite(latchpin,HIGH)
digitalWrite(latchpin,LOW)
}
voidpingPong()//showshowtheLEDslightup
{
intindex//setsupavariable
intdelayTime=100//setsupdelayvariable
for(index=0index<=7index++)
{
shiftWrite(index,HIGH)
//turnLEDon
delay(delayTime)
//pausetoslowdownthesequence
shiftWrite(index,LOW)
//turnLEDoff
}
for(index=7index>=0index)//turnsLEDsonandoffinorder
{
shiftWrite(index,HIGH)
//turnLEDon
delay(delayTime)
//pausetoslowdownthesequence
shiftWrite(index,LOW)
//turnLEDoff
}
}

You might also like