Variables not declared in scope

I am very new to Arduino, and am trying to create code for a school project. I have outlined variables in future void code but I keep receiving messages that the generate_sequence, show_sequence and get_sequence are 'not declared in this scope'. Any idea how to fix this? this is the section of my code:

if (level == 1)
{
 generate_sequence(); //generate a sequence;
 if (digitalRead(A4) == LOW || level != 1) //If start button is pressed or you're winning
 }
{
 show_sequence(); //show the sequence
 get_sequence(); //wait for your sequence
}
}

void show_sequence()
{
 digitalWrite(2, LOW);
 digitalWrite(3, LOW);
 digitalWrite(4, LOW);
 digitalWrite(5, LOW);

 for (int i = 0; i < level; i++)
 {
   digitalWrite(sequence[i], HIGH);
   delay(velocity);
   digitalWrite(sequence[i], LOW);
   delay(200);
 }
}
}
void get_sequence()
{
 int flag = 0; //this flag indicates if the sequence is correct

 for (int i = 0; i < level; i++)
 {
   flag = 0;
   while (flag == 0)
   {
     if (digitalRead(A0) == LOW)
     {
       digitalWrite(5, HIGH);
       your_sequence[i] = 5;
       flag = 1;
       delay(200);
       if (your_sequence[i] != sequence[i])
       {
         wrong_sequence();
         return;
       }
       digitalWrite(5, LOW);
     }

     if (digitalRead(A1) == LOW)
     {
       digitalWrite(4, HIGH);
       your_sequence[i] = 4;
       flag = 1;
       delay(200);
       if (your_sequence[i] != sequence[i])
       {
         wrong_sequence();
         return;
       }
       digitalWrite(4, LOW);
     }

     if (digitalRead(A2) == LOW)
     {
       digitalWrite(3, HIGH);
       your_sequence[i] = 3;
       flag = 1;
       delay(200);
       if (your_sequence[i] != sequence[i])
       {
         wrong_sequence();
         return;
       }
       digitalWrite(3, LOW);
     }

     if (digitalRead(A3) == LOW)
     {
       digitalWrite(2, HIGH);
       your_sequence[i] = 2;
       flag = 1;
       delay(200);
       if (your_sequence[i] != sequence[i])
       {
         wrong_sequence();
         return;
       }
       digitalWrite(2, LOW);
     }

   }
 }
 right_sequence();
}

void generate_sequence()
{
 randomSeed(millis()); //in this way is really random!!!

 for (int i = 0; i < MAX_LEVEL; i++)
 {
   sequence[i] = random(2, 6);
 }
}

check your brackets, as you can see (I indented the code you shared and used code tags) it seems there are many pairs of {} not matching


Don't post snippets (Snippets R Us!)

I can't really see where those would be. I'll attach my entire code if that's helpful. It's a code for simon says with a puzzle leading into a numbered password

#include <Keypad.h>

const int ROW_NUM = 4; //four rows
const int COLUMN_NUM = 3; //three columns

char keys[ROW_NUM][COLUMN_NUM] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte pin_rows[ROW_NUM] = {13, 12, 11, 10};
byte pin_column[COLUMN_NUM] = {9, 8, 7};

Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );

const String password = "2475";
String input_password;

const int MAX_LEVEL = 10;
int sequence[MAX_LEVEL];
int your_sequence[MAX_LEVEL];
int level = 1;

int velocity = 1000;

void setup() {
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  pinMode(A2, INPUT);
  pinMode(A3, INPUT);

  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);

  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
}

void loop() {
  char key = keypad.getKey();

  if (key) {
    Serial.println(key);

    if (key == '*') {
      input_password = ""; // clear input password
    } else if (key == '#') {
      if (password == input_password) {
        digitalWrite(2, LOW);
        digitalWrite(3, LOW);
        digitalWrite(4, LOW);
        digitalWrite(5, LOW);
        delay(250);

        digitalWrite(3, HIGH);
        digitalWrite(4, LOW);
        delay(1000);
        digitalWrite(3, LOW);
        digitalWrite(4, LOW);
        delay(500);
        digitalWrite(3, HIGH);
        digitalWrite(4, LOW);
        delay(1000);
        digitalWrite(3, LOW);
        digitalWrite(4, LOW);
        delay(500);
        digitalWrite(3, HIGH);
        digitalWrite(4, LOW);
        delay(1000);
        digitalWrite(3, LOW);
        digitalWrite(4, LOW);
        delay(500);
        digitalWrite(3, LOW);
        digitalWrite(4, HIGH);
        delay(1000);
        digitalWrite(3, LOW);
        digitalWrite(4, LOW);
        delay(500);
      } else {
        digitalWrite(2, HIGH);
        digitalWrite(3, HIGH);
        digitalWrite(4, HIGH);
        digitalWrite(5, HIGH);
        delay(250);
        digitalWrite(2, LOW);
        digitalWrite(3, LOW);
        digitalWrite(4, LOW);
        digitalWrite(5, LOW);
        delay(250);
      }

      input_password = ""; // clear input password
    } else {
      input_password += key; // append new character to input password string
    }
  }

  if (level == 1)
  {
    generate_sequence(); //generate a sequence;
    if (digitalRead(A4) == LOW || level != 1) //If start button is pressed or you're winning
    }
  {
    show_sequence();    //show the sequence
    get_sequence();     //wait for your sequence
  }
}

void show_sequence()
{
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);

  for (int i = 0; i < level; i++)
  {
    digitalWrite(sequence[i], HIGH);
    delay(velocity);
    digitalWrite(sequence[i], LOW);
    delay(200);
  }
}
}
void get_sequence()
{
  int flag = 0; //this flag indicates if the sequence is correct

  for (int i = 0; i < level; i++)
  {
    flag = 0;
    while (flag == 0)
    {
      if (digitalRead(A0) == LOW)
      {
        digitalWrite(5, HIGH);
        your_sequence[i] = 5;
        flag = 1;
        delay(200);
        if (your_sequence[i] != sequence[i])
        {
          wrong_sequence();
          return;
        }
        digitalWrite(5, LOW);
      }

      if (digitalRead(A1) == LOW)
      {
        digitalWrite(4, HIGH);
        your_sequence[i] = 4;
        flag = 1;
        delay(200);
        if (your_sequence[i] != sequence[i])
        {
          wrong_sequence();
          return;
        }
        digitalWrite(4, LOW);
      }

      if (digitalRead(A2) == LOW)
      {
        digitalWrite(3, HIGH);
        your_sequence[i] = 3;
        flag = 1;
        delay(200);
        if (your_sequence[i] != sequence[i])
        {
          wrong_sequence();
          return;
        }
        digitalWrite(3, LOW);
      }

      if (digitalRead(A3) == LOW)
      {
        digitalWrite(2, HIGH);
        your_sequence[i] = 2;
        flag = 1;
        delay(200);
        if (your_sequence[i] != sequence[i])
        {
          wrong_sequence();
          return;
        }
        digitalWrite(2, LOW);
      }

    }
  }
  right_sequence();
}

void generate_sequence()
{
  randomSeed(millis()); //in this way is really random!!!

  for (int i = 0; i < MAX_LEVEL; i++)
  {
    sequence[i] = random(2, 6);
  }
}
void wrong_sequence()
{
  for (int i = 0; i < 3; i++)
  {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    delay(250);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(250);
  }
  level = 1;
  velocity = 1000;
}

void right_sequence()
{
  if (level == 3) {  //round 3 reward: number 2 (0010)
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(250);

    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
  }
  else if (level == 5) { //round 5 reward: number 4 (0100)
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(250);

    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
  }
  else if (level == 8) { //round 8 reward: number 7 (0111)
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(250);

    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
  }
  else if (level == 10) { //round 10 reward: number 5 (0101)
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(250);

    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    delay(1000);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    delay(500);
  }
  else {
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(250);

    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    delay(500);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    delay(500);
  }
  if (level < MAX_LEVEL) {
    level++;
  }
  else if (level == 10) {
    level = 1;
    velocity = 1000;
  }
  else {
  }

  velocity -= 50; { //increase difficulty
  }
}

This is part of it:

Then show_sequence has an extra closing brace.