const int rows[8] = { 1, 2, 3, 4, 5, 6, 7, 8};
const int cols[8] = { 9, 10, 11, 12, 13, 14, 15, 16};
void setup()
{
for(int i = 22; i < 30; i++){
pinMode(i, INPUT_PULLUP);
}
pinMode(33, INPUT_PULLUP);
for( int i=0; i<8; i++)
{
pinMode(rows[i], OUTPUT);
pinMode(cols[i], OUTPUT);
digitalWrite(rows[i], HIGH);
digitalWrite(cols[i], LOW);
}
}
void loop()
{
int pattern[8][8] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
};
if(digitalRead(22)==LOW){
int pattern[8][8] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 1, 1, 1, 1, 0, 0},
{ 0, 1, 0, 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 0, 1, 1, 1, 1, 0, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 1, 0, 0, 0, 0, 1, 0},
{ 0, 0, 1, 1, 1, 1, 0, 0},
};
if(digitalRead(33)==LOW){
for(int i=0; i<10; i++){
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col+i], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col+i], LOW);
}
if(i>8){
i = -8;
}
delay(100);
}
}
else{
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col], LOW);
}
}
}
if(digitalRead(23)==LOW){
int pattern[8][8] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 1, 0},
{ 0, 1, 0, 0, 0, 0, 1, 0},
{ 0, 1, 0, 0, 0, 0, 1, 0},
{ 0, 1, 1, 1, 1, 1, 1, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
};
if(digitalRead(33)==LOW){
for(int i=0; i<10; i++){
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col+i], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col+i], LOW);
}
if(i>8){
i = -8;
}
delay(100);
}
}
else{
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col], LOW);
}
}
}
if(digitalRead(24)==LOW){
int pattern[8][8] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
};
if(digitalRead(33)==LOW){
for(int i=0; i<10; i++){
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col+i], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col+i], LOW);
}
if(i>8){
i = -8;
}
delay(100);
}
}
else{
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col], LOW);
}
}
}
if(digitalRead(25)==LOW){
int pattern[8][8] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 1, 1, 1, 1, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 1, 1, 1, 1, 0, 0},
};
if(digitalRead(33)==LOW){
for(int i=0; i<10; i++){
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col+i], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col+i], LOW);
}
if(i>8){
i = -8;
}
delay(100);
}
}
else{
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col], LOW);
}
}
}
if(digitalRead(26)==LOW){
int pattern[8][8] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 1, 1, 1, 0, 0},
{ 0, 0, 1, 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 0, 1, 0, 0},
{ 0, 0, 0, 0, 1, 0, 0, 0},
{ 0, 0, 0, 1, 0, 0, 0, 0},
{ 0, 0, 1, 1, 1, 1, 1, 0},
};
if(digitalRead(33)==LOW){
for(int i=0; i<10; i++){
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col+i], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col+i], LOW);
}
if(i>8){
i = -8;
}
delay(100);
}
}
else{
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col], LOW);
}
}
}
if(digitalRead(27)==LOW){
int pattern[8][8] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 1, 1, 1, 1, 0, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
};
if(digitalRead(33)==LOW){
for(int i=0; i<10; i++){
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col+i], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col+i], LOW);
}
if(i>8){
i = -8;
}
delay(100);
}
}
else{
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col], LOW);
}
}
}
if(digitalRead(28)==LOW){
int pattern[8][8] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 1, 1, 1, 1, 1, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 1, 1, 1, 1, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
};
if(digitalRead(33)==LOW){
for(int i=0; i<10; i++){
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col+i], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col+i], LOW);
}
if(i>8){
i = -8;
}
delay(100);
}
}
else{
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col], LOW);
}
}
}
if(digitalRead(29)==LOW){
int pattern[8][8] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 1, 1, 1, 1, 1, 1, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 1, 1, 1, 1, 1, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0},
{ 0, 1, 0, 0, 0, 0, 1, 0},
{ 0, 0, 1, 1, 1, 1, 0, 0},
};
if(digitalRead(33)==LOW){
for(int i=0; i<10; i++){
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col+i], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col+i], LOW);
}
if(i>8){
i = -8;
}
delay(100);
}
}
else{
for(int col=0; col<8; col++)
{
// activate this row.
digitalWrite( cols[col], HIGH);
// Turn on the colums that need to be lit
for( int row=0; row<8; row++)
{
if( pattern[row][col] == 1)
{
digitalWrite( rows[row], LOW);
}
}
// Wait, so the leds are visible
// Turn off the leds (I turn all of them off)
for( int row=0; row<8; row++)
{
digitalWrite( rows[row], HIGH);
}
// Done with this row, de-activate it
digitalWrite( cols[col], LOW);
}
}
}
else{
int pattern[8][8] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0},
};
}
}