   
   
   pinMode(hangPin, INPUT);
+  pinMode(dialPin, INPUT);
+  pinMode(countPin, INPUT);
   pinMode(ledPin, OUTPUT);
 
   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");

dir_t dirBuf;     // buffer for directory reads

const int hangPin = 6; //pin for reciever switch. closed (HIGH) when hung up, open (LOW) when off the hook
const int dialPin = 7; //pin for dialing switch. close (HIGH) when  dialing, open (LOW) when not dialing
const int countPin = 8; //pin for counting switch.  closed (HIGH) for don't count, open (LOW) for each count
const int ledPin = 13; //LED pin

int dialCount = 0;
#define DIAL_ARRAY_LEN 10
int dialArray[DIAL_ARRAY_LEN];
int dialIndex = 0;

int p1[] = {1, 2, 3, 4};
const int p1_len = 4;
int p2[] = {0, 9, 8, 7};
const int p2_len = 4;

int ledState = HIGH;
int hangState; //current reciever reading
int dialState; //current dial reading
int countState;
int lastHangState = LOW; //previous reciever reading
int lastDialState = LOW; //previous dial reading
int lastCountState = LOW;

long lastHangDebounceTime = 0;  // the last time the reciever pin was toggled
long lastDialDebounceTime = 0; // last time the dial switch was toggled
long lastCountDebounceTime = 0;
const long debounceDelay = 50;    // the debounce time; increase if the output flickers
const long countDebounceDelay = 10;

State phoneState = nodial;

void playfile(char *name) {
  if (wave.isplaying) {
