   if ((millis() - lastHangDebounceTime) > debounceDelay) { //then the bounce settled
     if (hangReading != hangState) {//then reciever state has changed
       hangState = hangReading;
-      ledState = hangState;   
       
       if(hangState == LOW) {//if first time off hook, start dial tone
-        dialState = nodial;
+        phoneState = nodial;
+        putstring_nl("hang low");
       }   
-    }
-  }
-  
-  //debounce the reciever switch
-  if (hangReading != lastHangState) {
-    lastHangDebounceTime = millis();
-  }
-
-  if ((millis() - lastHangDebounceTime) > debounceDelay) { //then the bounce settled
-    if (hangReading != hangState) {//then reciever state has changed
-      hangState = hangReading;
-      ledState = hangState;   
-      
-      if(hangState == LOW) {//if first time off hook, start dial tone
-        dialState = nodial;
-      }   
-    }
-  }
+      else {
+        putstring_nl("hang high");
+      }
+    }
+  }
+  
+  
 
   digitalWrite(ledPin, ledState);
 

    //stop any playback
    wave.stop();
    //reset any state
  }
  else {//off the hook
    switch(dialState) {
      case nodial:
        if(!wave.isplaying) {//if stopped playing, start again
          playfile("DIALTONE.WAV");


void loop() {
  int hangReading = digitalRead(hangPin);
  int dialReading = digitalRead(dialPin);
  int countReading = digitalRead(countPin);
  
  //debounce the reciever switch
  if (hangReading != lastHangState) {
