help with 8x8 led matrix program

hello all,
im new to arduino i just received it in the mail a few weeks ago i go to school for electronics and havent really gotten much on the software side i doing a project and i built an 8x8 led matrix. i want to have my matrix display numbers so that it can keep score for the game im building. i got some codes off of the net for a guide but it only flashes a 2 and then shuts off. can someone please lead me in the right direction heres the code

// 2-dimensional array of row pin numbers:
const int rownum[8] = {
10,12,15,17,2,4,6,8 };
// 2-dimensional array of column pin numbers:
const int colnum[8] = {
11,14,16,18,3,5,7,9  };

int buttonPin = 13;

int state = 0;

int row(int i) {
if(i == 1) {
return 10;
} else if (i == 2) {
return 12;
} else if (i == 3) {
return 15;
} else if (i == 4) {
return 17;
} else if (i == 5) {
return 2;
} else if (i == 6) {
return 4;
} else if (i == 7) {
return 6;
} else if (i == 8) {
return 8;
}
}

int col(int i) {
if(i == 1) {
return 11;
} else if (i == 2) {
return 14;
} else if (i == 3) {
return 16;
} else if (i == 4) {
return 18;
} else if (i == 5) {
return 3;
} else if (i == 6) {
return 5;
} else if (i == 7) {
return 7;
} else if (i == 8) {
return 9;
}
}

  void drawScreen(int character[8][8]) {
for(int j = 0; j < 8; j++) {
// Turn the row on
int rowNumber = j + 1;
digitalWrite(row(rowNumber), LOW);
for (int k = 0; k < 8; k++) {
// draw some letter bits
int columnNumber = k + 1;
if(character[j][k] == 1) {
digitalWrite(col(columnNumber), HIGH);
}

digitalWrite(col(columnNumber), LOW);
}
digitalWrite(row(rowNumber), HIGH);
}
}

int one[8][8] = {
{0,1,1,1,1,1,1,0},  // i havent done all of these yet i think im doing the right though
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int two[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int three[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int four[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int five[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int six[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int seven[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int eight[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int nine[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int ten[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int eleven[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int twelve[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int thirteen[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int fourteen[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int fifteen[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int sixteen[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int seventeen[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};


void setup() {
Serial.begin(9600);
// initialize the I/O pins as outputs:

// iterate over the pins:
for (int thisPin = 0; thisPin < 8; thisPin++) {
// initialize the output pins:
pinMode(colnum[thisPin], OUTPUT);
pinMode(rownum[thisPin], OUTPUT);
pinMode(buttonPin, INPUT);
// take the col pins (i.e. the cathodes) high to ensure that
// the LEDS are off:
digitalWrite(colnum[thisPin], LOW);
digitalWrite(rownum[thisPin], HIGH);
}

}


void loop() {
  
    if (digitalRead(buttonPin)); 
  {
      if (state == 0) 
    {
  drawScreen(one);
  state = 1;
  
  } else if (state == 1) {
  
  drawScreen(two);
  state = 2;
  } else if (state == 2) {
  
  drawScreen(three);
  state = 3;
  } else if (state == 3) {
  
  drawScreen(four);
  state = 4;
  } else if (state == 4) {
  
  drawScreen(five);
  state = 5;
  } else if (state == 5) {
  
  drawScreen(six);
  state = 6;
  } else if (state == 6) {
  
  drawScreen(seven);
  state = 7;
  } else if (state == 7) {
  
  drawScreen(eight);
  state = 8;
  } else if (state == 8) {
  
  drawScreen(nine);
  state = 9;
  } else if (state == 9) {
  
  drawScreen(ten);
  state = 10;
  } else if (state == 10) {
  
  drawScreen(eleven);
  state = 11;
  } else if (state == 11) {
  
  drawScreen(twelve);
  state = 12;
  } else if (state == 12) {
  
  drawScreen(thirteen);
  state = 13;
  } else if (state == 13) {
  
  drawScreen(four);
  state = 14;
  } else if (state == 14) {
  
  drawScreen(fourteen);
  state = 15;
  } else if (state == 15) {
  
  drawScreen(fifteen);
  state = 16;
  } else if (state == 16) {
 
  drawScreen(sixteen);
  state = 17;
  }
  }
}

Moderator edit: code placed in tags.

Maybe u only a two becuase uve programmed all ur arrays to show 2. look at the 1's in the matrix they all make 2's ...

int one[8][8] = {
{0,1,1,1,1,1,1,0},  // i havent done all of these yet i think im doing the right though
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int two[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

int three[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

maybe if u change int one to look like a one... (each 1 means the corresponding led is on a 0 means its off) int one[8][8] = { {0,0,0,0,1,0,0,0}, {0,0,0,1,1,0,0,0}, {0,0,1,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,1,1,1,1,1,1,1}, {0,0,0,0,0,0,0,0}};= see now the one's look a one :D now do the same with each number.

int col(int i) {
if(i == 1) {
return 11;
} else if (i == 2) {
return 14;
} else if (i == 3) {
return 16;
} else if (i == 4) {
return 18;
} else if (i == 5) {
return 3;
} else if (i == 6) {
return 5;
} else if (i == 7) {
return 7;
} else if (i == 8) {
return 9;
}
}

This isn't a PIC - you're allowed to have real lookup tables.

You have 18 * 8 * 8 * 2 bytes used up in those matrices - how many bytes of RAM do you actually have?

Effectively, you're using over 2k bytes of RAM (which may not exist) to store 144 bytes worth of information.

thanks for the replies im using the duemilanove. i changed all of them to be the number i want represented but same problem still just flashes a 2 im not gonna lie i reall y dont know what the heck im doing i just want to push a button and the numbers 1-? show on my matrix

i changed all of them to be the number i want represented but same problem still just flashes

So, you're still using more RAM than you actually have. Make the matrices "byte" instead of "int". Better yet, make them simple bitmaps.

so i made them bytes and im still getting a 2 and thats it, i also changed all the map to represent the number i want here are the changes ive made

// 2-dimensional array of row pin numbers:
const byte rownum[8] = {
10,12,15,17,2,4,6,8 };
// 2-dimensional array of column pin numbers:
const byte colnum[8] = {
11,14,16,18,3,5,7,9  };

byte buttonPin = 13;

byte state = 0;

byte row(byte i) {
if(i == 1) {
return 10;
} else if (i == 2) {
return 12;
} else if (i == 3) {
return 15;
} else if (i == 4) {
return 17;
} else if (i == 5) {
return 2;
} else if (i == 6) {
return 4;
} else if (i == 7) {
return 6;
} else if (i == 8) {
return 8;
}
}

byte col(byte i) {
if(i == 1) {
return 11;
} else if (i == 2) {
return 14;
} else if (i == 3) {
return 16;
} else if (i == 4) {
return 18;
} else if (i == 5) {
return 3;
} else if (i == 6) {
return 5;
} else if (i == 7) {
return 7;
} else if (i == 8) {
return 9;
}
}

  void drawScreen(byte character[8][8]) {
for(byte j = 0; j < 8; j++) {
// Turn the row on
byte rowNumber = j + 1;
digitalWrite(row(rowNumber), LOW);
for (byte k = 0; k < 8; k++) {
// draw some letter bits
byte columnNumber = k + 1;
if(character[j][k] == 1) {
digitalWrite(col(columnNumber), HIGH);
}

digitalWrite(col(columnNumber), LOW);
}
digitalWrite(row(rowNumber), HIGH);
}
}

byte one[8][8] = {
{0,1,1,1,1,0,0,0},
{0,1,0,0,1,0,0,0},
{0,0,0,0,1,0,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,1,0,0,0},
{0,0,0,1,1,0,0,0},
{0,0,0,0,1,0,0,0},
{0,0,1,1,1,1,1,0}};

byte two[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,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,0,0,0,0,0},
{0,0,1,1,1,1,1,0}};

byte three[8][8] = {
{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,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,1,1,1,1,1,0}};

byte four[8][8] = {
{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,0,0,0,0,1,0},
{0,1,1,1,1,1,1,0},
{0,0,0,1,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,0,0,0,0,1,0}};

byte five[8][8] = {
{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,0,0,0,1,0,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,1,1,1,1,1,0}};

byte six[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,0,0,0,0,1,0},
{0,1,0,0,0,1,0,0},
{0,1,1,1,1,1,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}};

byte seven[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,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,0,0,0,0,0},
{0,1,0,0,0,0,0,0}};

byte eight[8][8] = {
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,0,0,0,0,1,0},
{0,0,1,0,0,1,0,0},
{0,0,0,1,1,0,0,0},
{0,0,1,1,0,1,1,0},
{0,1,1,0,0,0,1,0},
{0,1,1,1,1,1,1,0}};

byte nine[8][8] = {
{0,1,1,1,1,1,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},
{0,0,0,0,0,0,1,0}};

byte ten[8][8] = {
{0,1,0,1,1,1,1,0},
{0,1,0,1,0,0,1,0},
{0,1,0,1,0,0,1,0},
{0,1,0,1,0,0,1,0},
{0,1,0,1,0,0,1,0},
{0,1,0,1,0,0,1,0},
{0,1,0,1,0,0,1,0},
{0,1,0,1,1,1,1,0}};

byte eleven[8][8] = {
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0}};

byte twelve[8][8] = {
{0,0,1,0,1,1,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,1,1,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,1,1,1,0}};

byte thirteen[8][8] = {
{0,0,1,0,1,1,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,1,1,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,1,1,1,0}};

byte fourteen[8][8] = {
{0,0,1,0,1,0,1,0},
{0,0,1,0,1,0,1,0},
{0,0,1,0,1,0,1,0},
{0,0,1,0,1,1,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,1,1,1,0}};

byte fifteen[8][8] = {
{0,0,1,0,1,1,1,0},
{0,0,1,0,1,0,0,0},
{0,0,1,0,1,0,0,0},
{0,0,1,0,1,1,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,1,1,1,0}};

byte sixteen[8][8] = {
{0,0,1,0,1,1,1,0},
{0,0,1,0,1,0,0,0},
{0,0,1,0,1,0,0,0},
{0,0,1,0,1,1,1,0},
{0,0,1,0,1,0,1,0},
{0,0,1,0,1,0,1,0},
{0,0,1,0,1,0,1,0},
{0,0,1,0,1,1,1,0}};

byte seventeen[8][8] = {
{0,0,1,0,1,1,1,0},
{0,0,1,0,1,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0}};


void setup() {
Serial.begin(9600);
// initialize the I/O pins as outputs:

// iterate over the pins:
for (int thisPin = 0; thisPin < 8; thisPin++) {
// initialize the output pins:
pinMode(colnum[thisPin], OUTPUT);
pinMode(rownum[thisPin], OUTPUT);
pinMode(buttonPin, INPUT);
// take the col pins (i.e. the cathodes) high to ensure that
// the LEDS are off:
digitalWrite(colnum[thisPin], LOW);
digitalWrite(rownum[thisPin], HIGH);
}

}


void loop() {
  
    if (digitalRead(buttonPin)); 
  {
      if (state == 0) 
    {
  drawScreen(one);
  state = 1;
  
  } else if (state == 1) {
  
  drawScreen(two);
  state = 2;
  } else if (state == 2) {
  
  drawScreen(three);
  state = 3;
  } else if (state == 3) {
  
  drawScreen(four);
  state = 4;
  } else if (state == 4) {
  
  drawScreen(five);
  state = 5;
  } else if (state == 5) {
  
  drawScreen(six);
  state = 6;
  } else if (state == 6) {
  
  drawScreen(seven);
  state = 7;
  } else if (state == 7) {
  
  drawScreen(eight);
  state = 8;
  } else if (state == 8) {
  
  drawScreen(nine);
  state = 9;
  } else if (state == 9) {
  
  drawScreen(ten);
  state = 10;
  } else if (state == 10) {
  
  drawScreen(eleven);
  state = 11;
  } else if (state == 11) {
  
  drawScreen(twelve);
  state = 12;
  } else if (state == 12) {
  
  drawScreen(thirteen);
  state = 13;
  } else if (state == 13) {
  
  drawScreen(four);
  state = 14;
  } else if (state == 14) {
  
  drawScreen(fourteen);
  state = 15;
  } else if (state == 15) {
  
  drawScreen(fifteen);
  state = 16;
  } else if (state == 16) {
 
  drawScreen(sixteen);
  state = 17;
  }
  }
}

Cut it down to 1 to 10.
Which processor do you have?
Even 17 * 8 * 8 is more than 1k bytes.

duemilanove

atmega 328

i cut it down to ten im starting to belive that this part of the code is the problem i just dont know enough to figure out why

byte row(byte i) {
if(i == 1) {
return 10;
} else if (i == 2) {
return 12;
} else if (i == 3) {
return 15;
} else if (i == 4) {
return 17;
} else if (i == 5) {
return 2;
} else if (i == 6) {
return 4;
} else if (i == 7) {
return 6;
} else if (i == 8) {
return 8;
}
}

byte col(byte i) {
if(i == 1) {
return 11;
} else if (i == 2) {
return 14;
} else if (i == 3) {
return 16;
} else if (i == 4) {
return 18;
} else if (i == 5) {
return 3;
} else if (i == 6) {
return 5;
} else if (i == 7) {
return 7;
} else if (i == 8) {
return 9;
}
}

  void drawScreen(byte character[8][8]) {
for(byte j = 0; j < 8; j++) {
// Turn the row on
byte rowNumber = j + 1;
digitalWrite(row(rowNumber), LOW);
for (byte k = 0; k < 8; k++) {
// draw some letter bits
byte columnNumber = k + 1;
if(character[j][k] == 1) {
digitalWrite(col(columnNumber), HIGH);
}

digitalWrite(col(columnNumber), LOW);
}
digitalWrite(row(rowNumber), HIGH);
}
}

Move up to a processor with more ... stuff

http://www.crossroadsfencing.com/BobuinoRev17

i think maybe its because i dont have anything in my program telling it to store the numbers. could this be the problem?? and if so how would i add this and where?

im starting to belive that this part of the code is the problem

See reply #2

i think maybe its because i dont have anything in my program telling it to store the numbers

No idea what you’re referring to there.

Handy hint: The IDE has an auto-format tool built itn (ctrl-T) - use it before you post your code.

 if (digitalRead(buttonPin));

That’s not going to help

so what should i put there instead

I'd lose the semicolon (I'm assuming that's what you're talking about) I'd also worry about what happens when "state" runs off the end.

I think the semicolon at the end keeps the stuff in { } from happening as you expected Try it with out it

drawScreen(sixteen); state = 17;

Yes, probably want to go to state = 0 at the end to restart.

Bear in mind also that there are no delays in that sketch - it is all going to happen very quickly.

so i changed the code the way u guys said to i think. now nothing shows at all and my button doesnt work i am completly lost i just want the program to put the nuber in when the button is pressed here is my new code can some please please fix it for me… thanks for all your help by the way maybe im just not understanding what u guys are telling me to do

// 2-dimensional array of row pin numbers:
const byte rownum[8] = {
  10,12,15,17,2,4,6,8 };
// 2-dimensional array of column pin numbers:
const byte colnum[8] = {
  11,14,16,18,3,5,7,9  };

byte buttonPin = 13;

int val = 0;

byte state = 0;

byte row(byte i) {
  if(i == 1) {
    return 10;
  } 
  else if (i == 2) {
    return 12;
  } 
  else if (i == 3) {
    return 15;
  } 
  else if (i == 4) {
    return 17;
  } 
  else if (i == 5) {
    return 2;
  } 
  else if (i == 6) {
    return 4;
  } 
  else if (i == 7) {
    return 6;
  } 
  else if (i == 8) {
    return 8;
  }
}

byte col(byte i) {
  if(i == 1) {
    return 11;
  } 
  else if (i == 2) {
    return 14;
  } 
  else if (i == 3) {
    return 16;
  } 
  else if (i == 4) {
    return 18;
  } 
  else if (i == 5) {
    return 3;
  } 
  else if (i == 6) {
    return 5;
  } 
  else if (i == 7) {
    return 7;
  } 
  else if (i == 8) {
    return 9;
  }
}

void drawScreen(byte character[8][8]) {
  for(byte j = 0; j < 8; j++) {
    // Turn the row on
    byte rowNumber = j + 1;
    digitalWrite(row(rowNumber), LOW);
    for (byte k = 0; k < 8; k++) {
      // draw some letter bits
      byte columnNumber = k + 1;
      if(character[j][k] == 1) {
        digitalWrite(col(columnNumber), HIGH);
      }

      digitalWrite(col(columnNumber), LOW);
    }
    digitalWrite(row(rowNumber), HIGH);
  }
}

byte one[8][8] = {
  {
    0,1,1,1,1,0,0,0      }
  ,
  {
    0,1,0,0,1,0,0,0      }
  ,
  {
    0,0,0,0,1,0,0,0      }
  ,
  {
    0,0,0,0,1,1,0,0      }
  ,
  {
    0,0,0,0,1,0,0,0      }
  ,
  {
    0,0,0,1,1,0,0,0      }
  ,
  {
    0,0,0,0,1,0,0,0      }
  ,
  {
    0,0,1,1,1,1,1,0      }
};

byte two[8][8] = {
  {
    0,1,1,1,1,1,1,0      }
  ,
  {
    0,1,0,0,0,0,1,0      }
  ,
  {
    0,1,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,0,0,0,0,0      }
  ,
  {
    0,0,1,1,1,1,1,0      }
};

byte three[8][8] = {
  {
    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,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,1,1,1,1,1,0      }
};

byte four[8][8] = {
  {
    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,0,0,0,0,1,0      }
  ,
  {
    0,1,1,1,1,1,1,0      }
  ,
  {
    0,0,0,1,0,0,1,0      }
  ,
  {
    0,0,1,0,0,0,1,0      }
  ,
  {
    0,0,0,0,0,0,1,0      }
};

byte five[8][8] = {
  {
    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,0,0,0,1,0,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,1,1,1,1,1,0      }
};

byte six[8][8] = {
  {
    0,1,1,1,1,1,1,0      }
  ,
  {
    0,1,0,0,0,0,1,0      }
  ,
  {
    0,1,0,0,0,0,1,0      }
  ,
  {
    0,1,0,0,0,1,0,0      }
  ,
  {
    0,1,1,1,1,1,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      }
};

byte seven[8][8] = {
  {
    0,1,1,1,1,1,1,0      }
  ,
  {
    0,1,0,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,0,0,0,0,0      }
  ,
  {
    0,1,0,0,0,0,0,0      }
};

byte eight[8][8] = {
  {
    0,1,1,1,1,1,1,0      }
  ,
  {
    0,1,0,0,0,0,1,0      }
  ,
  {
    0,1,0,0,0,0,1,0      }
  ,
  {
    0,0,1,0,0,1,0,0      }
  ,
  {
    0,0,0,1,1,0,0,0      }
  ,
  {
    0,0,1,1,0,1,1,0      }
  ,
  {
    0,1,1,0,0,0,1,0      }
  ,
  {
    0,1,1,1,1,1,1,0      }
};


void setup() {
  Serial.begin(9600);
  // initialize the I/O pins as outputs:

  // iterate over the pins:
  for (int thisPin = 0; thisPin < 8; thisPin++) {
    // initialize the output pins:
    pinMode(colnum[thisPin], OUTPUT);
    pinMode(rownum[thisPin], OUTPUT);
    pinMode(buttonPin, INPUT);
    // take the col pins (i.e. the cathodes) high to ensure that
    // the LEDS are off:
    digitalWrite(colnum[thisPin], LOW);
    digitalWrite(rownum[thisPin], HIGH);
  }

}


void loop() {

  if (digitalRead(buttonPin)) 

    if (state == 0) 
    {
      drawScreen(one);
      state = 1;

    } 
    else if (state == 1) {

      drawScreen(two);
      state = 2;
    } 
    else if (state == 2) {

      drawScreen(three);
      state = 3;
    } 
    else if (state == 3) {

      drawScreen(four);
      state = 4;
    } 
    else if (state == 4) {

      drawScreen(five);
      state = 5;
    } 
    else if (state == 5) {

      drawScreen(six);
      state = 6;
    } 
    else if (state == 6) {

      drawScreen(seven);
      state = 7;
    } 
    else if (state == 7) {

      drawScreen(eight);
      state = 8;
    } 
    else if (state == 8) {
      {
        drawScreen(one);
        state = 0;
      }
      delay(400);
    }
}

Does any of this:

byte row(byte i) {
  if(i == 1) {
    return 10;
  } 
  else if (i == 2) {
    return 12;
  } 
  else if (i == 3) {
    return 15;
  } 
  else if (i == 4) {
    return 17;
  } 
  else if (i == 5) {
    return 2;
  } 
  else if (i == 6) {
    return 4;
  } 
  else if (i == 7) {
    return 6;
  } 
  else if (i == 8) {
    return 8;
  }
}

look anything like any of this: const byte rownum[8] = {  10,12,15,17,2,4,6,8 }; ?