servo 360º control with a pushbutton use end switch


hello all i try to creat a code for this exemple but i dont have sucess can help de code i use is this

#include <Servo.h>
Servo myservo0;
//Set Pinouts->Sensors, buttons, LEDs
const byte btn0 = 5;
const byte endStopBottom0 = 9;
const byte endStopTop0 = 8;
boolean btn0ClickedUp = false;
boolean btn0ClickedDown = false;
int pos0 = 0;
int dir = 180;
int esq = 0;
void setup() {
  Serial.begin(115200);
  PinoutConfig();
}//END void setup()

void loop() {

  if(btn0ClickedUp && !endStopTop0){
    myservo0.write(pos0);
    delay(15);
  }
  else if(btn0ClickedDown && !endStopBottom0){
    myservo0.write(dir);
    delay(15);
  }

  //Serial.print("Servo0 position: ");
  //Serial.println(pos0);
  
}//END void loop()



//Config
void PinoutConfig() {
  myservo0.attach(10);
  pinMode(btn0, INPUT);
  //podes utilizar o INPUT_PULLUP nos pinos que tiverem
  attachInterrupt(digitalPinToInterrupt(btn0), btn0Click, RISING); //FALLING or RISING depende se está em pull-up ou pull-down
  pinMode(endStopBottom0, INPUT);
  pinMode(endStopTop0, INPUT);
}//END void PinoutConfig()

//Buttons functions
void btn0Click() {
  if(digitalRead(endStopBottom0)){
    btn0ClickedUp = true;
    btn0ClickedDown = false;
  }
  else if(digitalRead(endStopTop0)){
    btn0ClickedUp = false;
    btn0ClickedDown = true;
  }
}//END btn0Click()

i dont have sucess

What happens when you run the code ?

How are the servos powered (I can't tell from the picture) ?
What state will the inputs be in when the buttons are not pressed and what will keep them in that state ?

the image is ilustrative for i wont to make but when i run the code nothing is happen

  if (btn0ClickedUp && !endStopTop0)

What part of the code changes the value of btn0ClickedUp and endStopTop0 ?

this code is make a friend and i try to understand the code :cold_sweat: now i try this code

#include <Servo.h>
const byte pushbt = 5; 
const byte switchend1 = 8;
const byte switchend2 = 9;
const byte servoPin = 10;
Servo servo;
byte pushbtstate = LOW;
byte end1state = LOW;
byte end2state = LOW;
byte Pos = 0;
byte esq =180; // new
byte dir = 0; // new
byte stop = 90;

void setup() {
   Serial.begin(9600);
   pinMode(pushbt, INPUT);
   pinMode(switchend1, INPUT_PULLUP);
   pinMode(switchend2, INPUT_PULLUP);
  servo.attach(servoPin);
}
void loop () {
   readButtons();
   moveServo();
   moveStop1();
   moveStop2();
}
/////////////////////////////////////////////////////////////////////////////////
void readButtons() {
   pushbtstate = digitalRead(pushbt);
   end1state = digitalRead(switchend1);
   end2state = digitalRead(switchend2);
}
////////////////////////////////////////////////////////////////////////////////
void moveServo() {
   if (pushbtstate == LOW) {
     if (Pos == esq) { 
        Pos = dir;
     }
     else {
       Pos = esq;
     }
     pushbtstate = HIGH; 
   }
   servo.write(Pos);
   delay(200);
   Serial.print("Servo0 position: ");
   Serial.println(Pos);
}
/////////////////////////////////////////////////////////////////////////////////////
void moveStop1()    //pin8   top                              
{
   if (end1state == LOW){
   if (Pos == stop) { 
        Pos = stop;
     }
     else {
       Pos = stop;
     }
     end1state = HIGH; 
   }
  servo.write(stop);
}
///////////////////////////////////////////////////////////////////////////////////////
void moveStop2()         //pin9   buttom                         
{
   if (end2state == LOW){
   if (Pos == stop) { 
        Pos = stop;
     }
     else {
       Pos = stop;
     }
     end2state = HIGH; 
   }
  servo.write(stop);
 
}