Need help with the error: a function-definition is not allowed here before ' {'

please help, im cain of new in arduino and i made this code but i keep reciving the same error and i don't know what's wrong. here is the code:

void setup() {
  for (int i=2;i<=11;i++) {
    pinMode(i,OUTPUT);
  }
  pinMode(12,INPUT);
  pinMode(13,INPUT);
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  pinMode(A2,INPUT);

  int boton=0;

  //Funcion que prende y apaga un led y pone un delay
  void flash(int led, int tiempo){
    digitalWrite(led,1);
    delay(tiempo);
    digitalWrite(led,0);
    delay(tiempo);
  }

  //Funcion que prende y apaga 5 leds con un delay entre medias
  void flash5(int led1,int led2,int led3,int led4,int led5, int tiempo) {
    digitalWrite(led1,1);
    digitalWrite(led2,1);
    digitalWrite(led3,1);
    digitalWrite(led4,1);
    digitalWrite(led5,1);
    delay(tiempo);
    digitalWrite(led1,0);
    digitalWrite(led2,0);
    digitalWrite(led3,0);
    digitalWrite(led4,0);
    digitalWrite(led5,0);
    delay(tiempo);
  }

  //Funcion que prende 3 leds
  void flash1(int led1,int led2,int led3){
    digitalWrite(led1,1);
    digitalWrite(led2,1);
    digitalWrite(led3,1);
  }
  //Funcion que prende 4 leds
  void flash2(int led1,int led2,int led3,int led4){
    digitalWrite(led1,1);
    digitalWrite(led2,1);
    digitalWrite(led3,1);
    digitalWrite(led4,1);
  }
  //Funcion que apaga 3 leds
  void flash3(int led1,int led2,int led3,int tiempo){
    digitalWrite(led1,0);
    digitalWrite(led2,0);
    digitalWrite(led3,0);
    delay(tiempo);
  }
  //Funcion que apaga 4 leds
  void flash4(int led1,int led2,int led3,int led4,int tiempo){
    digitalWrite(led1,0);
    digitalWrite(led2,0);
    digitalWrite(led3,0);
    digitalWrite(led4,);
    delay(tiempo);
  }

  //Funcion de la animacion 1
  void animacion1() {
    flash5(2,4,6,8,10,30);
    flash5(2,4,6,8,10,30);
    flash5(3,5,7,9,11,30);
    flash5(3,5,7,9,11,30);
  }

  //Funcion de la animacion 2
  void animacion2() {
    flash1(3,6,9);
    flash4(2,5,8,11,30);
    flash2(2,5,8,11);
    flash3(4,7,10,30);
    flash1(4,7,10);
    flash3(3,6,9,30);
  }

  //Funcion de la animacion 3
  void animacion3() {
    flash1(3,5,7);
    delay(30);
    flash3(3,5,7,30);
    flash1(6,8,10);
    delay(30);
    flash3(6,8,10,30);
    flash2(9,11,2,4);
    delay(30);
    flash4(9,11,2,4,30);
  }

  //Funcion de la animacion de los leds aleatorios
  void aleatorio() {
    int aleatorio=random(2,11);
    if(aleatorio==2) {
      flash(2,30);
      flash(2,30);
      }
      else if(aleatorio==3) {
      flash(3,30);
      flash(3,30);
      }
      else if(aleatorio==4) {
      flash(4,30);
      flash(4,30);
      }
      else if(aleatorio==5) {
      flash(5,30);
      flash(5,30);
      }
      else if(aleatorio==6) {
      flash(6,30);
      flash(6,30);
      }
      else if(aleatorio==7) {
      flash(7,30);
      flash(7,30);
      }
      else if(aleatorio==8) {
      flash(8,30);
      flash(8,30);
      }
      else if(aleatorio==9) {
      flash(9,30);
      flash(9,30);
      }
      else if(aleatorio==10) {
      flash(10,30);
      flash(10,30);
      }
      else if(aleatorio==11) {
      flash(11,30);
      flash(11,30);
    }
  }

  //Funcion para parar las animaciones
  void parar() {
    for(int i=2;i<=11;i++) {
      digitalWrite(i,0);
    }
  }
}

void loop() {
  if (digitalRead(12)==1) {
    boton=1;
    delay(300);
  }
  else if (digitalRead(13)==1) {
    boton=2;
    delay(300);
  }
  else if (digitalRead(A0)==1) {
    boton=3;
    delay(300);
  }
  else if (digitalRead(A1)==1) {
    boton=4;
    delay(300);
  }
  else if (digitalRead(A2)==1) {
    boton=5;
    delay(300);
  }

  switch(boton) {
    case 1: animacion1();
    break;
    case 2: animacion2();
    break;
    case 3: animacion3();
    break;
    case 4: aleatorio();
    break;
    case 5: parar();
    break;
  }

}

All of your functions [except loop()] are inside the setup() function. Look carefully where the braces {} match up.

what exactly does this mean "All of your functions [except loop()] are inside the setup() function"?
also i check all the braces, all of them match, i even count them, there's 24 "{" and 24 "}"
idk what's wrong :frowning:

idk what's wrong :frowning:

Where does setup start and end?

A function definition/declaration, can not be inside another function. Therefore, the function definitions can not be within the open and closing braces of either setup() or loop() which are functions in themselves.

See this reference
https://www.arduino.cc/en/Reference/FunctionDeclaration

You are missing a closing brace.

You have a couple of other errors, but if this is a school project, say so.

Use CTRL-T to format your sketch and your second error will become obvious.

yes, it's a school project haha, i pressed ctrl+t but it says "no changes needed for auto format"
what does that mean?

That means that indentations were already 'correct'

void setup() {
...
...
  void flash(int led, int tiempo){
  ...
  ...

The fact that void flash does not start at the beginning of a line after an auto format indicates that it's defined inside another function. In this case, as indicated by others, means that you're missing a } before that function declaration.

Try this

void setup() {
...
...
}

void flash(int led, int tiempo){
  ...
  ...