Can't execute the void loop with subroutines

Hello everyone, sorry for this topic but i can't get out of this.

#include <Servo.h>
Servo servo1;
Servo servo2;
int bottone = 2;
int mossasel = 0;
int testmove = 0;

void setup() {
  servo1.attach(9);
  servo2.attach(10);
  pinMode (bottone, INPUT);
}

void loop() {
  if (testmove != 0) {
    mossasel = testmove;
  }


  if (digitalRead) (bottone == HIGH); {

    if (mossasel > 2) {
      mossasel = 0;
    }
    if (mossasel == 0) {
      mossa1();
    }
    else if (mossasel == 1) {
      mossa2();
    }
    if (testmove == 0) {
      mossasel++;
    }
    else {
      servo1.write (0);
      servo2.write (0);
    }
  }
}

here's the problem, when i upload the cod on my arduino it keeps executing a random positioning with the first servo. Actually i think the problem is when i have to increase the variable for change the subroutine of the servos.
The code should work, when the switch is HIGH it has to do the first subroutine, then the servo will turn off the switch. Then when it comes the second input from the HIGH switch it has to do the second subroutine of movement... then restarts from 0.
Hope you guys can help me.

The only servo movement commands that you have in the code that you posted are

    else 
    {
      servo1.write (0);
      servo2.write (0);
    }

What do the mossa functions do ?

How are the servos powered ?

The servo are powered with the first pin to +V the second to GRD and the last one to the Pin 10/9 of the arduino.
The all code is here

#include <Servo.h>
Servo servo1;
Servo servo2;
int bottone = 2;
int mossasel = 0;
int testmove = 0;

void setup() {
  servo1.attach(9);
  servo2.attach(10);
  pinMode (bottone, INPUT);
}

void loop() {
  if (testmove != 0) {
    mossasel = testmove;
  }


  if (digitalRead) (bottone == HIGH); {

    if (mossasel > 2) {
      mossasel = 0;
    }
    if (mossasel == 0) {
      mossa1();
    }
    else if (mossasel == 1) {
      mossa2();
    }
    if (testmove == 0) {
      mossasel++;
    }
    else {
      servo1.write (0);
      servo2.write (0);
    }
  }
}

void mossa1 () {
  servo1.write(180);
  delay(500);
  servo2.write(180);
  delay(700);
  servo2.write(0);
  delay(750);
}

void mossa2 () {
  servo1.write (180);
  delay(500);
  servo2.write (120);
  delay (25);
  servo2.write (30);
  delay (50);
  servo2.write (180);
  delay (700);
  servo2.write (0);
  delay (750);
}

before i didn't write the subroutines...
The problem is the arduino can't increase the variable to change the subroutine it has to do.

  if (digitalRead) (bottone == HIGH); {

Oops.

As AWOL hints, change this:-

if (digitalRead) (bottone == HIGH); {

to this:-

if(digitalRead(bottone) == HIGH) {

Also, 'testmove' is never altered during execution, so this does nothing:-

if (testmove != 0) {
    mossasel = testmove;
  }

and these will never be called:-

else {
      servo1.write (0);
      servo2.write (0);
    }

Maybe this is intentional.

'testmove' is never altered during execution,

Unless it is done in the mysterious functions that we have not seen.

UKHeliBob:
Unless it is done in the mysterious functions that we have not seen.

Bob, you must have missed it, but the full code was posted in reply #2. (Or at least I think it was the full code.)

Yes i've posted the full code.
Everytime the switch is running high i have to do a different subroutine.
Feel free to tell me i'm a dumbass and to change all of my code!!
The project is a uselessbox, with the servo wich everytime it works is gonna pull LOW the switch.
Actually the problem is i can't increase the variable in function of the subroutine i'm running.
For ex:
I = 0 --> SUB1
I++
1 = 1 --> SUB2
...
...
I = 10 --> I = 0

then restart.
Everytime i have to I++ when the switch triggers from Low to High

So, post your corrected code.

Feel free to tell me i'm a dumbass

OK. You're a dumbass.

Lots of issues have been identified in your code. You may, or may not, have fixed them, but changing the code on your computer does NOT change the code in this thread. There is a manual step required (of you).

even if i changed the code the problem it's still the same.
if you want you can modify the code up i've posted, or change it at all lol..
i'm sorry sigh..
just the part when i have to increase the variable..

OldSteve:
Bob, you must have missed it, but the full code was posted in reply #2. (Or at least I think it was the full code.)

You are right, I missed it. Thanks

Just post your code as it is now

#include <Servo.h>
Servo servo1;
Servo servo2;
int switch_pin = 2;
int selectedMove = 0;
int Testmove = 0;

void setup() {
  servo1.attach(9);
  servo2.attach(10);
  pinMode (switch_pin, INPUT);
}

void loop()
{
  if (Testmove != 0) {
    selectedMove = Testmove;
  }

  if(digitalRead(switch_pin) == HIGH)
  {

    if (selectedMove > 10) { 
      selectedMove = 0; 
    } 
    if (selectedMove == 0) { 
      mossa1(); 
    }
    else if (selectedMove == 1) { 
      mossa1(); 
    }  
    else if (selectedMove == 2) { 
      mossa2(); 
    }
  }
}

void mossa1 () {
  servo1.write(180);
  delay(500);
  servo2.write(180);
  delay(700);
  servo2.write(0);
  delay(750);
}

void mossa2 () {
  servo1.write (180);
  delay(500);
  servo2.write (120);
  delay (25);
  servo2.write (30);
  delay (50);
  servo2.write (180);
  delay (700);
  servo2.write (0);
  delay (750);
}
    if (selectedMove == 0) {
      mossa1();
    }
    else if (selectedMove == 1) {
      mossa1();
    }

You've not met the || operator yet?

What do your Serial.print()s tell you is happening? Why don't you have any?

You are not using the internal pullup resistor, so you need an external pullup or pulldown resistor wired with the switch. Just how IS the switched wired.

The code does something. You expect it to do something. "It doesn't work" doesn't tell us squat.

no i didn't :frowning:
that's my project for the exams high school.
I'm using a pulldown resistor for the switch, and i'm not using the serial print.. but i'm gonna try to see what the program is running.