SRAM overflow

int val [16][16]; //declare array for a 16x16 analog matrix sensor
int maxVal [16][16]; // needs to declare = 0, but done by default
int minVal [16][16]; // needs to be declared as 1023, still don't know how

those 3 arrays take up 1.5kB from the 2kB on the chip - if you can make them smaller (byte rather than int?) you'll save a lot of RAM space... Do you really need all 3 arrays?

And do use the code tags as above please.