74HC4067 with arduino uno

I have used this tutorial to interface 74HC4067 with arduino uno.

I have connected +5V to C0 to C15. But on the serial monitor values are different.

// control pins output table in array form
// see truth table on page 2 of TI 74HC4067 data sheet
// connect 74HC4067 S0~S3 to Arduino D7~D4 respectively
// connect 74HC4067 pin 1 to Arduino A0
byte controlPins[] = {B00000000, 
                  B10000000,
                  B01000000,
                  B11000000,
                  B00100000,
                  B10100000,
                  B01100000,
                  B11100000,
                  B00010000,
                  B10010000,
                  B01010000,
                  B11010000,
                  B00110000,
                  B10110000,
                  B01110000,
                  B11110000 }; 
 
// holds incoming values from 74HC4067                  
byte muxValues[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};
 
void setup()
{
  Serial.begin(9600);
  DDRD = B11111111; // set PORTD (digital 7~0) to outputs
}
 
void setPin(int outputPin)
// function to select pin on 74HC4067
{
  PORTD = controlPins[outputPin];
}
 
void displayData()
// dumps captured data from array to serial monitor
{
  Serial.println();
  Serial.println("Values from multiplexer:");
  Serial.println("========================");
  for (int i = 0; i < 16; i++)
  {
    Serial.print("input I"); 
    Serial.print(i); 
    Serial.print(" = "); 
    Serial.println(muxValues[i]);
  }
  Serial.println("========================");  
}
 
void loop()
{
  for (int i = 0; i < 16; i++)
  {
    setPin(15); // choose an input pin on the 74HC4067
    muxValues[i]=digitalRead(i); 
  }
 
  // display captured data
  displayData();
  delay(2000); 
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

Thanks, I had asked OP, but you beat him to it!

  for (int i = 0; i < 16; i++)
  {
    setPin(15); // choose an input pin on the 74HC4067
    muxValues[i]=digitalRead(i);
  }

You don’t select the mux pin (it’s always 15) but simply read all digital inputs of the Arduino.