Yet Another Beginner Question

Hi All! Doing the Arduino Dice project. Here is my code:
volatile int switchPin = 2;
int selectPin = 11;
bool spinReverse = false;
const int leds [6][6]{
{7, 0},
{3, 4, 0},
{1, 6, 7, 0},
{1, 2, 5, 6, 0},
{1, 2, 5, 6, 7, 0},
{1, 2, 3, 4, 5, 6}
};
const int spinnerLeds[6][1]{
{1},
{2},
{4},
{5},
{3},
};
volatile int buttonMenu = 0;
int buttonState = 0;
int randomRoll = 0;
int loopDelay = 400;
int rollDelay = 2000;
bool currentState = true;

void setup() {
pinMode(4 , OUTPUT);
pinMode(5 , OUTPUT);
pinMode(6 , OUTPUT);
pinMode(7 , OUTPUT);
pinMode(8 , OUTPUT);
pinMode(9 , OUTPUT);
pinMode(10 , OUTPUT);
pinMode(selectPin , INPUT_PULLUP);
pinMode(switchPin , INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(switchPin), SwitchButton, CHANGE);
TurnOff();
}

void loop() {
SelectButton();
switch (buttonMenu)
{
case 1:
{
if (currentState)
{
TurnOff();
}
currentState = false;
break;
}
case 2:
{
for (int i = 0; i < 6; i++)
{
TurnOn(i);
}
currentState = true;
break;
}
{
Spinner();
currentState = true;
break;

}
}

}

void SelectButton()
{
CheckButtonState();
if (buttonMenu == 99)
{
if (spinReverse)
{
SpinnerReverse();
}
else
{
Spinner();
}
}
randomSeed(analogRead(0));
randomRoll = random(0, 6);
Flash();

TurnOn(randomRoll);
delay(rollDelay);
TurnOff();
buttonMenu = 1;
}
}

void SwitchButton()
{
int reading = digitalRead(switchPin);
if (reading != buttonState) {
buttonState = reading;
if (buttonState == HIGH) {
buttonMenu++;
if (buttonMenu > 4)
{
buttonMenu = 1;
}
}
}

void CheckButtonState()
int currentReading = digitalRead(selectPin);
if (currentReading == 0)
{
buttonMenu = 99;
}
}

void TurnOff()
{
for (int x = 4; x < 11; x++)
{
digitalWrite(x, LOW);
}
}

void TurnAllOn()
{
for (int x = 4; x < 11; x++)
{
digitalWrite(x, HIGH);
}
}

void Flash()
{
for (int i = 0; i < 6; i++)
{
TurnAllOn();
delay(50);
TurnOff();
delay(50);
}
}

void Spinner()
{
for(int i = 0; i < 6; i++)
{
TurnOnLed(spinnerLeds*[0]);*

  • delay(60);*
  • }*
    }
    void SpinnerReverse()
    {
  • for (int i = 5; i >= 0; i--)*
  • {*
    _ TurnOnLed(spinnerLeds*[0]);_
    _
    delay(60);_
    _
    }_
    _
    }_
    void TurnOn(int dieRoll)
    _
    {_
    _
    TurnOff();_
    _
    for (int i = 0; i <= 6; i++)_
    _
    {_
    _ if (leds[dieRoll] == 0)
    {
    break;
    }
    TurnOnLed(leds[dieRoll]);
    }
    delay(loopDelay);
    }
    void TurnOnLed(int whichLed)
    {
    int newValue = whichLed + 3;
    if (digitalRead(newValue) == LOW)
    {
    digitalWrite(newValue, HIGH);
    }
    else*

    * {
    digitalWrite(newValue, LOW);
    }
    CheckButtonState();*_

* }*
And this is the error message:
In function 'void setup()':
sketch_jun19a:36: error: 'SwitchButton' was not declared in this scope
* attachInterrupt(digitalPinToInterrupt(switchPin), SwitchButton, CHANGE);*
* ^*
sketch_jun19a:37: error: 'TurnOff' was not declared in this scope
* TurnOff();*
* ^*
/Users/yogigirl/Documents/Arduino/sketch_jun19a/sketch_jun19a.ino: In function 'void loop()':
sketch_jun19a:48: error: 'TurnOff' was not declared in this scope
* TurnOff();*
* ^*
sketch_jun19a:57: error: 'TurnOn' was not declared in this scope
* TurnOn(i);*
* ^*
sketch_jun19a:63: error: 'Spinner' was not declared in this scope
* Spinner();*
* ^*
/Users/yogigirl/Documents/Arduino/sketch_jun19a/sketch_jun19a.ino: In function 'void SelectButton()':
sketch_jun19a:74: error: 'CheckButtonState' was not declared in this scope
* CheckButtonState();*
* ^*
sketch_jun19a:79: error: 'SpinnerReverse' was not declared in this scope
* SpinnerReverse();*
* ^*
sketch_jun19a:83: error: 'Spinner' was not declared in this scope
* Spinner();*
* ^*
sketch_jun19a:88: error: 'Flash' was not declared in this scope
* Flash();*
* ^*
sketch_jun19a:90: error: 'TurnOn' was not declared in this scope
* TurnOn(randomRoll);*
* ^*
sketch_jun19a:92: error: 'TurnOff' was not declared in this scope
* TurnOff();*
* ^*
/Users/yogigirl/Documents/Arduino/sketch_jun19a/sketch_jun19a.ino: At global scope:
sketch_jun19a:95: error: expected declaration before '}' token
}
^
exit status 1
'SwitchButton' was not declared in this scope
I know it is a bit, so if it is too much guidance to how find the solution appreciated! It is a code I copied. Thank you in advance for any and all the help!

went thru the code, missed one line, but it is primarily the "switchButton" error that I don't understand.

If you Auto Format your code in the IDE you will see that the Selectbutton() function looks like this

void SelectButton()
{
  CheckButtonState();
  if (buttonMenu == 99)
  {
    if (spinReverse)
    {
      SpinnerReverse();
    }
    else
    {
      Spinner();
    }
  }
  randomSeed(analogRead(0));
  randomRoll = random(0, 6);
  Flash();
  TurnOn(randomRoll);
  delay(rollDelay);
  TurnOff();
  buttonMenu = 1;
}
}

You have either on to many closing braces or one too few opening braces

thank you for the tip on the brackets! still getting the same "swtichButton" error tho...

and I will be the first to admit this project may be a bit above the level I am at, but hey thats how I learn.

Auto format the code and post it as it is now and please put it in code tags when you do

still getting the same "swtichButton" error

C/C++ in general, and the compiler that Arduino uses in particular, is notorious for giving you misleading error messages due to relatively unrelated errors. In this case you have:

void SwitchButton()
{
  int reading = digitalRead(switchPin);
  if (reading != buttonState) {
    buttonState = reading;
    if (buttonState == HIGH) {
      buttonMenu++;
      if (buttonMenu > 4)
      {
        buttonMenu = 1;
      }
    }
  }

  void CheckButtonState()
  int currentReading = digitalRead(selectPin);
  if (currentReading == 0)
  {
    buttonMenu = 99;
  }
 }

CheckButtonState() has a definition "inside" of SwitchButton() (probably due to a missing closing brace), which I guess causes an error in creating the SwitchButton() function (but not quite a "fatal" enough error to have it say "SwitchButton is bad" and stop.
It's hard to tell whether there are other errors - when we look at the code, or copy/paste it, some of the code has been changed into weird forum post formatting and/or smileys. That's why it is important to use "code tags" when posting code.

volatile int switchPin = 2;
int selectPin = 11;
bool spinReverse = false;
const int leds [6][6] {
  {7, 0},
  {3, 4, 0},
  {1, 6, 7, 0},
  {1, 2, 5, 6, 0},
  {1, 2, 5, 6, 7, 0},
  {1, 2, 3, 4, 5, 6}
};
const int spinnerLeds[6][1] {
  {1},
  {2},
  {4},
  {5},
  {3},
};
volatile int buttonMenu = 0;
int buttonState = 0;
int randomRoll = 0;
int loopDelay = 400;
int rollDelay = 2000;
bool currentState = true;

void setup() {
  pinMode(4 , OUTPUT);
  pinMode(5 , OUTPUT);
  pinMode(6 , OUTPUT);
  pinMode(7 , OUTPUT);
  pinMode(8 , OUTPUT);
  pinMode(9 , OUTPUT);
  pinMode(10 , OUTPUT);
  pinMode(selectPin , INPUT_PULLUP);
  pinMode(switchPin , INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(switchPin), SwitchButton, CHANGE);
  TurnOff();
}

void loop() {
  SelectButton();
  switch (buttonMenu)
  {
    case 1:
      {
        if (currentState)
        {
          TurnOff();
        }
        currentState = false;
        break;
      }
    case 2:
      {
        for (int i = 0; i < 6; i++)
        {
          TurnOn(i);
        }
        currentState = true;
        break;
      }
    case 3:
      {
        Spinner();
        currentState = true;
        break;
      }
    case 4:
      {
        SpinnerReverse();
        currentState = true;
        break;
      }
  }
}

void SelectButton()
{
  CheckButtonState();
  if (buttonMenu == 99)
  {
    spinReverse = !spinReverse;
    for (int x = 0; x < 6; x++)
    {
      if (spinReverse)
      {
        SpinnerReverse();
      }
      else
      {
        Spinner();
      }
    }
    randomSeed(analogRead(0));
    randomRoll = random(0, 6);
    Flash();

    TurnOn(randomRoll);
    delay(rollDelay);
    TurnOff();
    buttonMenu = 1;
  }


  void SwitchButton()
  {
    int reading = digitalRead(switchPin);
    if (reading != buttonState) {
      buttonState = reading;
      if (buttonState == HIGH) {
        buttonMenu++;
        if (buttonMenu > 4)
        {
          buttonMenu = 1;
        }
      }
    }
  }

  void CheckButtonState()
  {
    int currentReading = digitalRead(selectPin);
    if (currentReading == 0)
    {
      buttonMenu = 99;
    }
  }
  void TurnOff()
  {
    for (int x = 4; x < 11; x++)
    {
      digitalWrite(x, LOW);
    }
  }

  void TurnAllOn()
  {
    for (int x = 4; x < 11; x++)
    {
      digitalWrite(x, HIGH);
    }
  }

  void Flash()
  {
    for (int i = 0; i <= 6; i++)
    {
      TurnAllOn();
      delay(50);
      TurnOff();
      delay(50);
    }
  }

  void Spinner()
  {
    for (int i = 0; i < 6; i++)
    {
      TurnOnLed(spinnerLeds[i][0]);
      delay(60);
    }
  }

  void SpinnerReverse()
  {
    for (int i = 5; i >= 0; i--)
    {
      TurnOnLed(spinnerLeds[i][0]);
      delay(60);
    }
  }

  void TurnOn(int dieRoll)
  {
    TurnOff();
    for (int i = 0; i <= 6; i++)
    {
      if (leds[dieRoll][i] == 0)
      {
        break;
      }
      TurnOnLed(leds[dieRoll][i]);
    }
    delay(loopDelay);
  }

  void TurnOnLed(int whichLed)
  {
    int newValue = whichLed + 3;
    if (digitalRead(newValue) == LOW)
    {
      digitalWrite(newValue, HIGH);
    }
    else
    {
      digitalWrite(newValue, LOW);
    }
    CheckButtonState();

  }
/code]

Look at your code. When it is Auto Formatted in the IDE the last closing brace should be on the left margin. Where is it in your code ?

You still have one too may opening braces or one too few closing braces in several places.

Look where the SelectButton() function ends. Is the closing brace on the left margin ? Look carefully at your other functions too. Do they end with a closing brace on the left margin ?

it must have been the braces, because I went thru it again and it worked! thank you a bunch for your patience and pointing me in the right direction!