I'm trying to use a 16-channel capacitive touch sensor named [TTP229-BSF][1] with an Arduino Uno. I use the following code that doesn't work. When I touch the keys it detects the keys but also prints out some wrong keys before and after detecting the touched key. I linked the required jumper as shown in the attached picture.

What is the problem here? 

Is there a better and more robust way to do this based on the timing diagram of the datasheet that I attached? i tried using interrupts but it didn't work 

 

     #define SCL_PIN 9
    #define SDO_PIN 3
     byte Count;
      byte Key_State = 0;
    /* Used to store the key state */
    int Key1;
    
    void setup()
    {
      /* Initialise the serial interface */
      Serial.begin(9600);
      /* Configure the clock and data pins */
      pinMode(SCL_PIN, OUTPUT);
     
     
    }
    
    
    /* Main program */
    void loop()
    {
      /* Read the current state of the keypad */
      Key1 = Read_Keypad();
    
      /* If a key has been pressed output it to the serial port */
      if (Key1)
      {
        Serial.println(Key1);
      }
    
    
      /* Wait a little before reading again
         so not to flood the serial port*/
      delay(300);
    }
    
    
    /* Read the state of the keypad */
    byte Read_Keypad(void)
    {
     
      pinMode(SDO_PIN, OUTPUT);
      digitalWrite(SDO_PIN, LOW);
      delayMicroseconds(100);
      digitalWrite(SDO_PIN, HIGH);
      delayMicroseconds(100);
      digitalWrite(SDO_PIN, LOW);
      delayMicroseconds(20);
      pinMode(SDO_PIN, INPUT);
      /* Pulse the clock pin 16 times (one for each key of the keypad)
         and read the state of the data pin on each pulse */
      for (Count = 1; Count <= 16; Count++)
      {
        /* If the data pin is low (active low mode) then store the
           current key number */
        digitalWrite(SCL_PIN, HIGH);
        delayMicroseconds(100);
        if (digitalRead(SDO_PIN))
        Key_State = Count;
        digitalWrite(SCL_PIN, LOW);
        delayMicroseconds(100);
        
       
      }
      return Key_State;
    }

[![enter image description here][2]][2]
[![enter image description here][3]][3]
[![enter image description here][4]][4]


  [1]: https://www.sunrom.com/get/611100
  [2]: https://i.sstatic.net/CjxIr.png
  [3]: https://i.sstatic.net/RH7E2.png
  [4]: https://i.sstatic.net/B0aJG.png