 int count2 = 0; //The counter that iterates through the names, looking for a match with the requested note
 int MAX_COUNT = (sizeof(melody) - 1) / 2; //How many notes are in the melody
 int statePin = LOW;
-void speaker ();
+bool alarmSounding = false;
+void speaker();
 
 void setup() {
   pinMode(ledPin, OUTPUT);
   pinMode(sensorPin, INPUT);
-  digitalWrite(sensorPin, HIGH);
+  digitalWrite(sensorPin, HIGH); //Sets the pullup resistor //Used for testing purposes
   //Speaker is already set up by default as output
 }
 
 void loop() {
-  if (digitalRead (sensorPin) == LOW) {
+  if (digitalRead (sensorPin) == LOW) { //Used for testing purposes
     speaker();
   }
+  delay(100);
+  statePin = !statePin;
+  digitalWrite(ledPin, statePin);
 }
 
 void speaker() {
+  alarmSounding = true;
   analogWrite(speakerOut, 0); //Ensure speaker starts off
   for (count = 0; count < MAX_COUNT; count++) { //Iterates through the notes requested
     statePin = !statePin;


int ledPin = 13;
int speakerOut = 9;
int sensorPin = 5;
byte names[] = {'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C'};
int tones[] = {1915, 1700, 1519, 1432, 1275, 1136, 1014, 956};
byte melody[] = "3b3d"; //"3b3d3b3d3b3d3b3d";

      }
    }
  }
  alarmSounding = false;
}

//Base code from http://www.arduino.cc/en/Tutorial/PlayMelody
