Cannot read PORTC

Hi

Arduino Nano.

I want to read a binary switch on PORTC ,A0,A1,A2.Common pin to ground and 10k pullup resistors on A0,A1,A2.

Then output the value from the binary switch on PORTD.

If I run this all 3 leds on PORTD pulse on and off,but the binary switch does not change the leds.

 /*  TEST POTRD
    while(1)
    {

    PORTD = 0X00;
    delay(1000);
    PORTD = 0XFF;
    delay(1000);
    }
  */

Below is my full not working best effort.

void setup()
{

  DDRD = 0XFF;//PORTD all output

  pinMode (14, INPUT);
  pinMode (15, INPUT);
  pinMode (16, INPUT);
}

void loop()
{
  DataSelect = digitalRead(PORTC);//read portc
  DataSelect & B00000111;//mask off 5 upper bits

  /*  TEST POTRD
    while(1)
    {

    PORTD = 0X00;
    delay(1000);
    PORTD = 0XFF;
    delay(1000);
    }
  */

  if (DataSelect == 0)//1
  {
    PORTD = 0;
  }

  if (DataSelect == 1)//2
  {
    PORTD = 1;
  }
  if (DataSelect == 2)//3
  {
    PORTD = 2;
  }

  if (DataSelect == 3)//4
  {
    PORTD = 3;
  }
  if (DataSelect == 4)//5
  {
    PORTD = 4;
  }

  if (DataSelect == 5)//6
  {
    PORTD = 5;
  }
  if (DataSelect == 6)//7
  {
    PORTD = 6;
  }

  if (DataSelect == 7)//8
  {
    PORTD = 7;
  }



}

Please help..all the samples I could find only read single PINS.

Revised version of your codes -- validate the necessity.

void setup()
{

  DDRD = 0XFF;//PORTD all output

  pinMode (14, INPUT);
  pinMode (15, INPUT);
  pinMode (16, INPUT);
}

void loop()
{
  byte DataSelect = PINC;//digitalRead(PORTC);//read portc
  DataSelect = DataSelect & B00000111;//mask off 5 upper bits

  /*  TEST POTRD
    while(1)
    {

    PORTD = 0X00;
    delay(1000);
    PORTD = 0XFF;
    delay(1000);
    }
  */

  if (DataSelect == 0)//1
  {
    PORTD = 0;
  }

  if (DataSelect == 1)//2
  {
    PORTD = 1;
  }
  if (DataSelect == 2)//3
  {
    PORTD = 2;
  }

  if (DataSelect == 3)//4
  {
    PORTD = 3;
  }
  if (DataSelect == 4)//5
  {
    PORTD = 4;
  }

  if (DataSelect == 5)//6
  {
    PORTD = 5;
  }
  if (DataSelect == 6)//7
  {
    PORTD = 6;
  }

  if (DataSelect == 7)//8
  {
    PORTD = 7;
  }
}

Reference Reading:
pd2.png

pd2.png

Thanks Golamostafa

You fix my problem..it is working!

I searched for 2 day for this.

Thanks.