Using 4 buttons to switch between LED Matrix scenes

Hey! As stated in the title, I'm trying to make an LED wall that I can switch between different Glediator scenes, saved to an SD card, using 4 different buttons. I've got the electronics working without a hitch, but the programming is biting me in the arse! The below link is the code I've got thus far. The idea is that it loops through 'checkSensor' functions, and depending on the buttons state activates a scene from the 'triggerAnimation' array. I'm having a load of issues with it though and I'm not proficient enough at coding to know how to fix it :frowning:

These are the error codes I'm getting

AIMmatrix:230:15: error: expected constructor, destructor, or type conversion before ';' token

 checkSensor3();

               ^

AIMmatrix:231:1: error: expected unqualified-id before 'if'

 if (sensorState3 == LOW) {

 ^

exit status 1
expected constructor, destructor, or type conversion before ';' token

Any help would be much appreciated!

checkSensor3();
if (sensorState3 == LOW) {

See the problem now?

That code is outside your loop() function. You have your closing '}' in the wrong place.

This sort of thing really doesn't help

     }
                 
          }
      }
}

Try using the auto-format tool more often.

AWOL:

checkSensor3();

if (sensorState3 == LOW) {



See the problem now?

No I still don't :frowning: If I remove ; I just get

if (sensorState3 == LOW) {

 ^

exit status 1
expected constructor, destructor, or type conversion before 'if'

blh64:
That code is outside your loop() function. You have your closing '}' in the wrong place.

Thank you! I worked it out. The problem now is I don't have enough memory! Does anyone have advice on how I can shrink the code down at all? 4buttmatrix - Pastebin.com

use fewer LEDs or get a bigger board (mega)