const int rows[5] = { 2, 3, 4, 5, 6};
const int cols[5] = { 9, 10, 11, 12, 13};
const char pattern[5][5] =
{
{ '#',' ',' ',' ','#'},
{ ' ','#',' ','#',' '},
{ ' ',' ','#',' ',' '},
{ ' ','#',' ','#',' '},
{ '#',' ',' ',' ','#'},
};
void setup()
{
for( int i=0; i<5; i++)
{
pinMode(rows[i], OUTPUT);
pinMode(cols[i], OUTPUT);
}
}
void loop()
{
// Activate the rows one by one and set the columns
for(int row=0; row<5; row++)
{
// activate this row.
digitalWrite( rows[row], LOW);
// Turn on the colums that need to be lit
for( int col=0; col<5; col++)
{
if( pattern[row][col] == '#')
{
digitalWrite( cols[col], HIGH);
}
}
// Wait, so the leds are visible
delay(20);
// Turn off the leds (I turn all of them off)
for( int col=0; col<5; col++)
{
digitalWrite( cols[col], LOW);
}
// Done with this row, de-activate it
digitalWrite( rows[row], HIGH);
}
}