Problems with int errors

I have been writing this code, modified from here: Controlling 8x8 LED matrix without drivers & libraries - Arduino Project Hub, and I need to make it so that the image changes when I press a button. Here is the code:
Code:

[code]

#define R1 2
#define R2 3
#define R3 4
#define R4 5
#define R5 6
#define R6 7
#define R7 8
#define R8 9
//Columns
#define C1 10
#define C2 11
#define C3 12
#define C4 13
#define C5 A0
#define C6 A1
#define C7 A2
#define C8 A3
int mySwitch;
int displayEmoji;
const int switchPin = 14;
int switchState = 0;
int prevSwitchState = 0; 
int pause=300;

  int happyFace [8] [8] ={
  {0,0,0,0,0,0,0,0},
  {0,0,1,0,0,1,0,0},
  {0,0,1,0,0,1,0,0},
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0},
  {0,1,0,0,0,0,1,0},
  {0,0,1,1,1,1,0,0},
  {0,0,0,0,0,0,0,0},
  };

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


  int amazedFace [8] [8] ={
  {0,0,0,0,0,0,0,0},
  {0,0,1,0,0,1,0,0},
  {0,0,1,0,0,1,0,0},
  {0,0,0,0,0,0,0,0},
  {0,0,0,1,1,0,0,0},
  {0,0,1,0,0,1,0,0},
  {0,0,1,0,0,1,0,0},
  {0,0,0,1,1,0,0,0},
  };
  

  int boredFace [8] [8] ={
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0},
  {0,1,1,0,1,1,0,0},
  {0,0,0,0,0,0,0,0},
  {0,0,1,1,1,1,0,0},
  {0,0,0,0,0,1,0,0},
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0},
  };
 
  int excitedFace [8] [8] ={
  {0,0,0,0,0,0,0,0},
  {0,1,1,0,0,1,1,0},
  {0,1,1,0,0,1,1,0},
  {0,0,0,0,0,0,0,0},
  {0,0,1,1,1,1,0,0},
  {0,0,1,0,0,1,0,0},
  {0,0,0,1,1,0,0,0},
  {0,0,0,0,0,0,0,0},
  };


  int confusedFace [8] [8] ={
  {0,0,0,0,0,0,0,0},
  {0,1,1,0,0,1,1,0},
  {0,0,0,1,0,0,0,1},
  {0,0,1,0,0,0,1,0},
  {0,0,0,0,0,0,0,0},
  {0,0,1,0,0,0,1,0},
  {0,0,0,0,0,0,0,0},
  {0,0,0,1,1,1,0,0},
  };


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


void setup() {
   pinMode(R1, OUTPUT);
   pinMode(R2, OUTPUT);
   pinMode(R3, OUTPUT);
   pinMode(R4, OUTPUT);
   pinMode(R5, OUTPUT);
   pinMode(R6, OUTPUT);
   pinMode(R7, OUTPUT);
   pinMode(R8, OUTPUT);
   pinMode(C1, OUTPUT);
   pinMode(C2, OUTPUT);
   pinMode(C3, OUTPUT);
   pinMode(C4, OUTPUT);
   pinMode(C5, OUTPUT);
   pinMode(C6, OUTPUT);
   pinMode(C7, OUTPUT);
   pinMode(C8, OUTPUT);
   pinMode(switchPin, INPUT);
  digitalWrite(R1,HIGH);
  digitalWrite(R2,HIGH);
  digitalWrite(R3,HIGH);
  digitalWrite(R4,HIGH);
  digitalWrite(R5,HIGH);
  digitalWrite(R6,HIGH);
  digitalWrite(R7,HIGH);
  digitalWrite(R8,HIGH);
  digitalWrite(C1,LOW);
  digitalWrite(C2,LOW);
  digitalWrite(C3,LOW);
  digitalWrite(C4,LOW);
  digitalWrite(C5,LOW);
  digitalWrite(C6,LOW);
  digitalWrite(C7,LOW);
  digitalWrite(C8,LOW);
}



void SelectRow(int row){
  if (row==1) digitalWrite(R1,LOW); else digitalWrite(R1,HIGH);
  if (row==2) digitalWrite(R2,LOW); else digitalWrite(R2,HIGH);
  if (row==3) digitalWrite(R3,LOW); else digitalWrite(R3,HIGH);
  if (row==4) digitalWrite(R4,LOW); else digitalWrite(R4,HIGH);
  if (row==5) digitalWrite(R5,LOW); else digitalWrite(R5,HIGH);
  if (row==6) digitalWrite(R6,LOW); else digitalWrite(R6,HIGH);
  if (row==7) digitalWrite(R7,LOW); else digitalWrite(R7,HIGH);
  if (row==8) digitalWrite(R8,LOW); else digitalWrite(R8,HIGH);
}

void Set_LED_in_Active_Row(int column, int state){
  if (column==1) digitalWrite(C1,state); 
  if (column==2) digitalWrite(C2,state); 
  if (column==3) digitalWrite(C3,state); 
  if (column==4) digitalWrite(C4,state); 
  if (column==5) digitalWrite(C5,state); 
  if (column==6) digitalWrite(C6,state); 
  if (column==7) digitalWrite(C7,state); 
  if (column==8) digitalWrite(C8,state); 
}
void loop(){
 switchState = digitalRead(switchPin);
 if (switchState != prevSwitchState){
  if (switchState == LOW){
  if (mySwitch==0) displayEmoji = happyFace;
  if (mySwitch==1) displayEmoji = sadFace;
  if (mySwitch==2) displayEmoji = amazedFace;
  if (mySwitch==3) displayEmoji = boredFace;
  if (mySwitch==4) displayEmoji = excitedFace;
  if (mySwitch==5) displayEmoji = confusedFace;
  if (mySwitch==6) displayEmoji = angryFace;
  }
  mySwitch = mySwitch + 1 %7;
 }
 prevSwitchState = switchState;





    for (int j=0;j<8;j++){
    SelectRow(j+1);
      for (int i=0;i<8;i++){
        Set_LED_in_Active_Row(i+1 ,displayEmoji[j][i]);
      }
      delay(2+pause);
    }
if(pause!=0 and pause>100)pause=pause-100;
if(pause!=0 and pause<=100)pause=pause-10;
},

and I keep getting this error: invalid types 'int[int]' for array subscript

     Set_LED_in_Active_Row(i+1 ,displayEmoji[j][i]);

invalid types 'int[int]' for array subscript for this line. how can I fix that

You can't subscript a scalar

Please remember to use code tags when posting code

ok.

So you have an integer

and you have a 2D array

does this make sense?

what do you mean? how do I fix my problem?

I mean you can't assign the pointer of a 2D array to an int and expect the compiler to be happy about it.

by starting to add code tags to your first post. (read How to get the best out of this forum )

Sorry new here. what does that mean? what lines do I change, to what?

I'd make the emojis a 3 dimensional array, then you could use displayEmoji as the first subscript.

But I wouldn't waste as much memory on them as you have.

I can tell you if you read the rules and fix your first post by adding the code tags...

change what? how do I do that?

it's explained in the post How to get the best out of this forum you'll see a section titled Use code tags ➜ that's what expected (as well as all the rest)

did it.

please explain

what do you mean? I do nto understand.

I mean that each emoji bitmap is using 128 bytes of precious RAM to store eight bytes of data.

Instead of

 int happyFace [8] [8] ={
  {0,0,0,0,0,0,0,0},
  {0,0,1,0,0,1,0,0},
  {0,0,1,0,0,1,0,0},
  {0,0,0,0,0,0,0,0},
  {0,0,0,0,0,0,0,0},
  {0,1,0,0,0,0,1,0},
  {0,0,1,1,1,1,0,0},
  {0,0,0,0,0,0,0,0},
  };

It should look more like

 const byte  happyFace [8] ={
  0b00000000,
  0b00100100,
  0b00100100,
  0b00000000,
  0b00000000,
  0b01000010,
  0b00111100,
  0b00000000,
  };

And then, you can see the way to make this a 2 D array of all the emojis

oh. and then it can still fit into the variable displayEmoji? and also what does the 0b do?

try this code and look at the Serial monitor (115200 bauds)

const byte happyFace[8][8] = {
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 1, 0, 0, 1, 0, 0},
  {0, 0, 1, 0, 0, 1, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
  {0, 1, 0, 0, 0, 0, 1, 0},
  {0, 0, 1, 1, 1, 1, 0, 0},
  {0, 0, 0, 0, 0, 0, 0, 0},
};

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

const byte (*displayEmoji)[8] ;


const byte sadFaceCompact[8] = {
  0b00000000,
  0b00100100,
  0b00100100,
  0b00000000,
  0b00111100,
  0b01000010,
  0b00000000,
  0b00000000,
};

const byte *displayEmojiCompact;


void printDisplayEmoji() {
  for (byte i = 0; i < 8; i++) {
    Serial.write('{');
    for (byte j = 0; j < 8; j++) {
      Serial.print(displayEmoji[i][j]);
      Serial.write((j < 7) ? ',' : '}');
    }
    Serial.println();
  }
}

void printDisplayEmojiCompact() {
  for (byte i = 0; i < 8; i++) {
    Serial.write('{');
    for (char j = 7; j >= 0; j--) {
      Serial.print(bitRead(displayEmojiCompact[i], j));
      Serial.write((j != 0) ? ',' : '}');
    }
    Serial.println();
  }
}

void setup() {
  Serial.begin(115200); Serial.println();
  displayEmoji = happyFace;
  printDisplayEmoji();
  Serial.println();
  displayEmoji = sadFace;
  printDisplayEmoji();
  Serial.println();
  
  displayEmojiCompact = sadFaceCompact;
  printDisplayEmojiCompact();
}

void loop() {
}

Welcome

0b is prefix for binary notation. For example 0b00100100 is binary notation of number 36

Here is a small example how to use AWOL's code : lx2u6I - Online C++ Compiler & Debugging Tool - Ideone.com

where do I place that? as seperate code in a new project? I do nto understand what that does and why I need it.

remember it's a forum to help people learn - not to do it for them

So yes, run that as a fully separate project.

you need to study the code I provided. It will help. you understand how to define a variable that can refer to a 2D array (or one for a 1D array if you use the compact binary form)