const byte
rows = 3,
columns = 3,
rowpins [ rows ] = { 4, 3, 2 },
columnpins [ columns ] = { 10, 9, 8 }
;

boolean
currentState [ rows ] [ columns ],
previousState [ rows ] [ columns ]
;

void initialise ()
{
  Serial.println ( "Board initialising\n" );
  delay ( 2000 );
  Serial.println ( " ... \n" );
  delay ( 500 );
  Serial.println ( " ... " );
  
  for ( byte n = 0; n < rows; n ++ ) pinMode ( rowpins [ n ], INPUT_PULLUP );
  for ( byte n = 0; n < columns; n ++ ) pinMode ( columnpins [ n ], INPUT_PULLUP );
  
  for ( byte r = 0; r < rows; r ++ )
  {
    pinMode ( rowpins [ r ], OUTPUT ); digitalWrite ( rowpins [ r ], LOW );
    delayMicroseconds ( 20 );
    for ( byte c = 0; c < columns; c ++ )
    {
      previousState [ r ] [ c ] = currentState [ r ] [ c ];
      currentState [ r ] [ c ] = digitalRead ( columnpins [ c ] );
    }
    pinMode ( rowpins [ r ], INPUT_PULLUP );
  }
  
  delay ( 500 );
  Serial.println ( "\nCurrent Layout :\n");
  
  for ( byte r = 0; r < rows; r ++ )
  {
    for ( byte c = 0; c < columns; c ++ )
    {
      Serial.print ( "\t" );
      Serial.print ( currentState [ r ] [ c ] );
    }
    Serial.println ();
  }
}

void setup ()
{
  Serial.begin ( 115200 );
  delay ( 2000 );
  // initialise ();
}

void loop ()
{
  initialise ();
}