const byte
rows = 8,
columns = 8,
rowpins [ rows ] = { 23, 25, 27, 29, 31, 33, 35, 37 },
columnpins [ columns ] = { 13, 12, 11, 10, 9, 8, 7, 6 }
;
char
letter[8] = "abcdefgh",
number[8] = "87654321";
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 ();
}
Serial.println();
Serial.println();
Serial.println();
delay(2000);
Serial.println ( "\nPrevious Layout :\n");
for ( byte r = 0; r < rows; r ++ )
{
for ( byte c = 0; c < columns; c ++ )
{
Serial.print ( "\t" );
Serial.print ( previousState [ r ] [ c ] );
}
Serial.println ();
}
delay(2000);
}
void setup ()
{
Serial.begin ( 115200 );
delay ( 2000 );
for (byte i = 0; i < 8; i++) {
for (byte j = 0; j < 8; j++) {
currentState[i][j] = 1;
previousState[i][j] = 1;
}
}
}
void loop()
{
initialise();
for (byte i = 0; i < 8; i++) {
for (byte j = 0; j < 8; j++) {
if (currentState[i][j] != previousState[i][j]){
Serial.println(letter[j]);
Serial.println(number[i]);
Serial.println(letter[j] += number[i]);
}
}
}
}