Controlling Individual servos with individual buttons

You had several misplaced braces }

You take directions very well, congratulations.

Now you do realize that it is up to you to study the workings of the sketch and learn how it functions.

As mentioned, there are ways to make things easier on yourself when writing a program i.e. using a struct{ } and perhaps a class.



BTW
Always use CTRL T to format your sketches as this will make them easier to read.

//Forum https://forum.arduino.cc/t/controlling-individual-servos-with-individual-buttons/861547?u=larryd
//
//Non blocking servo control of 5 servos

//Version  YYMMDD   Description
// 1.00    210513   functional sketch
// 1.02    210513   made non-blocking
// 1.03    210514   added 4 more servos, total of 5

#include <Servo.h>

#define doNothing                 0
#define goingToMax                1
#define goingToMin                2

const byte heartbeatLED         = 13;

//****************************************
//first servo stuff
Servo firstServo;                 // pinky
const byte firstServoSwitch     = 2;
const byte firstServoAngle      = 170;
const byte firstServoAngleStep  = 10;
const byte firstServoPin        = 3;
byte lastSwitchStatefirstServo  = HIGH;
int firstPosition               = 0;
byte firstFSM                   = doNothing;
unsigned long firstMillis;

//****************************************
//second servo stuff
Servo secondServo;                 // ring
const byte secondServoSwitch     = 4;
const byte secondServoAngle      = 170;
const byte secondServoAngleStep  = 10;
const byte secondServoPin        = 5;
byte lastSwitchStatesecondServo  = HIGH;
int secondPosition               = 0;
byte secondFSM                   = doNothing;
unsigned long secondMillis;

//*********************************************
//third servo stuff
Servo thirdServo;                 // middle
const byte thirdServoSwitch     = 6;
const byte thirdServoAngle      = 170;
const byte thirdServoAngleStep  = 10;
const byte thirdServoPin        = 7;
byte lastSwitchStatethirdServo  = HIGH;
int thirdPosition               = 0;
byte thirdFSM                   = doNothing;
unsigned long thirdMillis;

//**********************************************
//fourth servo stuff
Servo fourthServo;                 // index
const byte fourthServoSwitch     = 8;
const byte fourthServoAngle      = 170;
const byte fourthServoAngleStep  = 10;
const byte fourthServoPin        = 9;
byte lastSwitchStatefourthServo  = HIGH;
int fourthPosition               = 0;
byte fourthFSM                   = doNothing;
unsigned long fourthMillis;

//***********************************************
//fifth servo stuff
Servo fifthServo;                 // thumb
const byte fifthServoSwitch     = 10;
const byte fifthServoAngle      = 170;
const byte fifthServoAngleStep  = 10;
const byte fifthServoPin        = 11;
byte lastSwitchStatefifthServo  = HIGH;
int fifthPosition               = 0;
byte fifthFSM                   = doNothing;
unsigned long fifthMillis;

//***********************************************
//timing stuff
unsigned long heartbeatMillis;
unsigned long switchMillis;


//*******************************************************************
void setup()
{
  pinMode(heartbeatLED, OUTPUT);

  //first servo
  firstServo.attach(firstServoPin);
  firstServo.write(0);
  pinMode(firstServoSwitch, INPUT_PULLUP);

  //second servo
  secondServo.attach(secondServoPin);
  secondServo.write(0);
  pinMode(secondServoSwitch, INPUT_PULLUP);

  //third servo
  thirdServo.attach(thirdServoPin);
  thirdServo.write(0);
  pinMode(thirdServoSwitch, INPUT_PULLUP);

  //fourth servo
  fourthServo.attach(fourthServoPin);
  fourthServo.write(0);
  pinMode(fourthServoSwitch, INPUT_PULLUP);

  //fifth servo
  fifthServo.attach(fifthServoPin);
  fifthServo.write(0);
  pinMode(fifthServoSwitch, INPUT_PULLUP);

} //END of setup()

//*******************************************************************
void loop()
{
  //*******************************
  //time to toggle the heartbeatLED ?
  if (millis() - heartbeatMillis >= 250)
  {
    //retart the Timer
    heartbeatMillis = millis();

    //toggle the LED
    digitalWrite(heartbeatLED, !digitalRead(heartbeatLED));
  }

  //*******************************
  //time to check the switches ?
  if (millis() - switchMillis >= 50)
  {
    //retart the Timer
    switchMillis = millis();

    checkSwitches();
  }

  //*******************************
  //check the FSM
  checkFSM();

} //END of loop()


//*******************************************************************
//Finite State Machine (FSM)
void checkFSM()
{
  //******************************************                          1
  //first state machine
  switch (firstFSM)
  {
    //***********
    case doNothing:
      {
        //do nothing
      }
      break;

    //***********
    case goingToMax:
      if (millis() - firstMillis >= 20)
      {
        //restart the TIMER
        firstMillis = millis();

        //move servo
        firstServo.write(firstPosition);

        //next position
        firstPosition = firstPosition + firstServoAngleStep;

        //at maximum ?
        if (firstPosition > firstServoAngle)
        {
          firstPosition = firstServoAngle;
          firstServo.write(firstPosition);

          //we are finished
          firstFSM = doNothing;
        }
      }
      break;

    //***********
    case goingToMin:
      if (millis() - firstMillis >= 20)
      {
        //restart the TIMER
        firstMillis = millis();

        //move servo
        firstServo.write(firstPosition);

        //next position
        firstPosition = firstPosition - firstServoAngleStep;

        //at minimum ?
        if (firstPosition <= 0)
        {
          firstPosition = 0;
          firstServo.write(firstPosition);

          //we are finished
          firstFSM = doNothing;
        }
      }
      break;
      
  } //END of switch/case

  //******************************************                          2
  //second state machine
  switch (secondFSM)
  {
    //***********
    case doNothing:
      {
        //do nothing
      }
      break;

    //***********
    case goingToMax:
      if (millis() - secondMillis >= 20)
      {
        //restart the TIMER
        secondMillis = millis();

        //move servo
        secondServo.write(secondPosition);

        //next position
        secondPosition = secondPosition + secondServoAngleStep;

        //at maximum ?
        if (secondPosition > secondServoAngle)
        {
          secondPosition = secondServoAngle;
          secondServo.write(secondPosition);

          //we are finished
          secondFSM = doNothing;
        }
      }
      break;

    //***********
    case goingToMin:
      if (millis() - secondMillis >= 20)
      {
        //restart the TIMER
        secondMillis = millis();

        //move servo
        secondServo.write(secondPosition);

        //next position
        secondPosition = secondPosition - secondServoAngleStep;

        //at minimum ?
        if (secondPosition <= 0)
        {
          secondPosition = 0;
          secondServo.write(secondPosition);

          //we are finished
          secondFSM = doNothing;
        }
      }
      break;
      
  } //END of switch/case

  //******************************************                          3
  // third state machine
  switch (thirdFSM)
  {
    //***********
    case doNothing:
      {
        //do nothing
      }
      break;

    //***********
    case goingToMax:
      if (millis() - thirdMillis >= 20)
      {
        //restart the TIMER
        thirdMillis = millis();

        //move servo
        thirdServo.write(thirdPosition);

        //next position
        thirdPosition = thirdPosition + thirdServoAngleStep;

        //at maximum ?
        if (thirdPosition > thirdServoAngle)
        {
          thirdPosition = thirdServoAngle;
          thirdServo.write(thirdPosition);

          //we are finished
          thirdFSM = doNothing;
        }
      }
      break;

    //***********
    case goingToMin:
      if (millis() - thirdMillis >= 20)
      {
        //restart the TIMER
        thirdMillis = millis();

        //move servo
        thirdServo.write(thirdPosition);

        //next position
        thirdPosition = thirdPosition - thirdServoAngleStep;

        //at minimum ?
        if (thirdPosition <= 0)
        {
          thirdPosition = 0;
          thirdServo.write(thirdPosition);

          //we are finished
          thirdFSM = doNothing;
        }
      }
      break;
      
  } //END of switch/case

  //******************************************                          4
  // fourth state machine
  switch (fourthFSM)
  {
    //***********
    case doNothing:
      {
        //do nothing
      }
      break;

    //***********
    case goingToMax:
      if (millis() - fourthMillis >= 20)
      {
        //restart the TIMER
        fourthMillis = millis();

        //move servo
        fourthServo.write(fourthPosition);

        //next position
        fourthPosition = fourthPosition + fourthServoAngleStep;

        //at maximum ?
        if (fourthPosition > fourthServoAngle)
        {
          fourthPosition = fourthServoAngle;
          fourthServo.write(fourthPosition);

          //we are finished
          fourthFSM = doNothing;
        }
      }
      break;

    //***********
    case goingToMin:
      if (millis() - fourthMillis >= 20)
      {
        //restart the TIMER
        fourthMillis = millis();

        //move servo
        fourthServo.write(fourthPosition);

        //next position
        fourthPosition = fourthPosition - fourthServoAngleStep;

        //at minimum ?
        if (fourthPosition <= 0)
        {
          fourthPosition = 0;
          fourthServo.write(fourthPosition);

          //we are finished
          fourthFSM = doNothing;
        }
      }
      break;
      
  } //END of switch/case

  //******************************************                          5
  // fifth state machine
  switch (fifthFSM)
  {
    //***********
    case doNothing:
      {
        //do nothing
      }
      break;

    //***********
    case goingToMax:
      if (millis() - fifthMillis >= 20)
      {
        //restart the TIMER
        fifthMillis = millis();

        //move servo
        fifthServo.write(fifthPosition);

        //next position
        fifthPosition = fifthPosition + fifthServoAngleStep;

        //at maximum ?
        if (fifthPosition > fifthServoAngle)
        {
          fifthPosition = fifthServoAngle;
          fifthServo.write(fifthPosition);

          //we are finished
          fifthFSM = doNothing;
        }
      }
      break;

    //***********
    case goingToMin:
      if (millis() - fifthMillis >= 20)
      {
        //restart the TIMER
        fifthMillis = millis();

        //move servo
        fifthServo.write(fifthPosition);

        //next position
        fifthPosition = fifthPosition - fifthServoAngleStep;

        //at minimum ?
        if (fifthPosition <= 0)
        {
          fifthPosition = 0;
          fifthServo.write(fifthPosition);

          //we are finished
          fifthFSM = doNothing;
        }
      }
      break;
      
  } //END of switch/case
  
  //******************************************                      DONE

} //END of checkFSM()


//*******************************************************************
void checkSwitches()
{
  //reusable variable
  byte state;
  
  //******************************************                          1
  //change state first servo switch ?
  state = digitalRead(firstServoSwitch);

  //******************************
  if (lastSwitchStatefirstServo != state)
  {
    //update to the new state
    lastSwitchStatefirstServo = state;

    //***************
    //first servo switch is pushed ?
    if (state == LOW)
    {
      //restart the TIMER
      firstMillis = millis();

      firstFSM = goingToMax;
    }

    //***************
    //first servo switch is released ?
    else
    {
      //restart the TIMER
      firstMillis = millis();

      firstFSM = goingToMin;
    }
  }

  //******************************************                          2
  //change state second servo switch ?
  state = digitalRead(secondServoSwitch);

  //******************************
  if (lastSwitchStatesecondServo != state)
  {
    //update to the new state
    lastSwitchStatesecondServo = state;

    //***************
    //second servo switch is pushed ?
    if (state == LOW)
    {
      //restart the TIMER
      secondMillis = millis();

      secondFSM = goingToMax;
    }

    //***************
    //second servo switch is released ?
    else
    {
      //restart the TIMER
      secondMillis = millis();

      secondFSM = goingToMin;
    }
  }

  //******************************************                          3
  //change state third servo switch ?
  state = digitalRead(thirdServoSwitch);

  //******************************
  if (lastSwitchStatethirdServo != state)
  {
    //update to the new state
    lastSwitchStatethirdServo = state;

    //***************
    //third servo switch is pushed ?
    if (state == LOW)
    {
      //restart the TIMER
      thirdMillis = millis();

      thirdFSM = goingToMax;
    }

    //***************
    //third servo switch is released ?
    else
    {
      //restart the TIMER
      thirdMillis = millis();

      thirdFSM = goingToMin;
    }
  }

  //******************************************                          4
  //change state fourth servo switch ?
  state = digitalRead(fourthServoSwitch);

  //******************************
  if (lastSwitchStatefourthServo != state)
  {
    //update to the new state
    lastSwitchStatefourthServo = state;

    //***************
    //fourth servo switch is pushed ?
    if (state == LOW)
    {
      //restart the TIMER
      fourthMillis = millis();

      fourthFSM = goingToMax;
    }

    //***************
    //fourth servo switch is released ?
    else
    {
      //restart the TIMER
      fourthMillis = millis();

      fourthFSM = goingToMin;
    }
  }

  //******************************************                          5
  //change state fifth servo switch ?
  state = digitalRead(fifthServoSwitch);

  //******************************
  if (lastSwitchStatefifthServo != state)
  {
    //update to the new state
    lastSwitchStatefifthServo = state;

    //***************
    //fifth servo switch is pushed ?
    if (state == LOW)
    {
      //restart the TIMER
      fifthMillis = millis();

      fifthFSM = goingToMax;
    }

    //***************
    //fifth servo switch is released ?
    else
    {
      //restart the TIMER
      fifthMillis = millis();

      fifthFSM = goingToMin;
    }
  }

  //******************************


}//END of checkSwitches()


//*******************************************************************



And

You cannot power your 5 servos from the USB cable or the Arduino 5v pin.

You must use an external 5v (6v) power supply; the GND must be common with the Arduino GND.