arduino + MT8870

I found the attached code online for someone who has already started playing around with DTMF. The code gets me started. I haven't programed much but was able to follow what was going on in the code more or less.

I have built a circuit to decode the DTMF signals properly and the hardware is working 100%. I want to be able to monitor the dialpad number pressed on my phone in the serial monitor. The thing is I am getting sporadic errors. I know the hardware works because I have LEDs built into the circuit to display the dialpad number in binary and they light up properly. This is what the serial monitor looks like when I go through the dialpad

Key : 1
Key : 1
Key : 3
Key : 4
Key : 5
Key : 1
Key : 1
Key : 8
Key : 1
Key : 1
Key : 0
Key : 1

what i should be getting is

Key : 1
Key : 2
Key : 3
Key : 4
Key : 5
Key : 6
Key : 7
Key : 8
Key : 9
Key : *
Key : 0
Key : #

its like it defaulting to Key : 1 here and there. I have messed with the delay() function and that has made it better but its still random here and there.

Does anyone have any clue what might be causing this and also maybe a way to make the code a little more simple?

Thanks your help is greatly appreciated. This isn't for a school project. Just a hobby of mine
-Dan

#define stD_PIN  2   // stD Port, verifies a valid DTMF tone
#define D0_PIN   3   // Binary Data Port 0
#define D1_PIN   4   // Binary Data Port 1
#define D2_PIN   5   // Binary Data Port 2
#define D3_PIN   6   // Binary Data Port 3


byte stD_state;

void setup()
{
 // Configures Serial Port @ 9600,8,N,1
 Serial.begin(9600);
 
 // Configure PIN mode
 pinMode(stD_PIN, INPUT); 
 pinMode(D0_PIN, INPUT); 
 pinMode(D1_PIN, INPUT); 
 pinMode(D2_PIN, INPUT); 
 pinMode(D3_PIN, INPUT); 
   
}

void loop()
{
 // Checks for valid tone 
 stD_state = digitalRead(stD_PIN);
    
 if (stD_state == 1)
    {
      Serial.print("Key : ");
      char key = read_code(); // Reads DTMF code
      Serial.println(key); // Prints the key received
      delay(350);          // Pause to syncronize the signal
     

    }
}
/*-------------------------------------------------------------*/
byte read_code()
{
 byte data;           // Variable Que Tiene El Valor byte De La tecla
 char key;            // Variable Que Tiene El Valor Char  tecla
 
 byte D0,D1,D2,D3;    // Variable Donde Se Lee el Estado
 
 // Determines if D0...D3 is (1 or 0 , ON orOFF )
 D0 = digitalRead(D0_PIN);
 D1 = digitalRead(D1_PIN);
 D2 = digitalRead(D2_PIN);
 D3 = digitalRead(D3_PIN);
 
 // Covierte De Binario A BYTE o ENTERO
 // Escribe Los BITS En Una Variable dato
 bitWrite(data,0,D0);
 bitWrite(data,1,D1);
 bitWrite(data,2,D2);
 bitWrite(data,3,D3);

// Converts the key to CHAR
 if (data == 1) key = '1';
 if (data == 2) key = '2';
 if (data == 3) key = '3';
 if (data == 4) key = '4';
 if (data == 5) key = '5';
 if (data == 6) key = '6';
 if (data == 7) key = '7';
 if (data == 8) key = '8';
 if (data == 9) key = '9';
 
 if (data == 10) key = '0';
 if (data == 11) key = '*';
 if (data == 12) key = '#';

return key;
}

There's someone with almost exactly the same problme here:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1284828366/0#0

yeah i posted in two different places hoping that i might get some more replies

Don't - it winds people up the wrong way and wastes time.

my mistake. There have just been no hits yet today.

I'm still getting random "1's" where I shouldn't be getting them?

I have played around with initializing things like that since I know it is better programing practice but still the error persists.