I keep on getting an error.. HELP!

#include <Servo.h>

Servo myservo1; // create servo object to control a servo
// twelve servo objects can be created on most boards

Servo myservo2; // create servo object to control a servo

Servo myservo3; // create servo object to control a servo

int pos = 0; // variable to store the servo position

void setup() {
myservo1.attach(9); // attaches the servo on pin 9 to the servo object
myservo2.attach(8); // attaches the servo on pin 8 to the servo object
myservo3.attach(7); // attaches the servo on pin 7 to the servo object
}

void loop() {
int randNumber = random(1, 3);
Serial.println(randNumber);

int del = random(1000, 16,000);
Serial.println(randNumber);

delay (del);

if randNumber = myservo1

// in steps of 1 degree
myservo1.write(90);
// in steps of 1 degree
myservo2.write(90);

// in steps of 1 degree
myservo3.write(90);

delay(2000);
myservo1.write(pos); // tell servo to go to position in variable ‘pos’
myservo2.write(pos);
myservo3.write(pos);
// waits 15ms for the servo to reach the position
}
}

this is not defined "myservo "

delay(2000);
myservo.write(0); // tell servo to go to position in variable 'pos'
// waits 15ms for the servo to reach the position

i think you need to do this

delay(2000);
myservo1.write(pos);
myservo2.write(pos);

this is working for me

a55830:
delay(2000);
myservo.write(0); // tell servo to go to position in variable 'pos'
// waits 15ms for the servo to reach the position

i think you need to do this

delay(2000);
myservo1.write(pos);
myservo2.write(pos);

this is working for me

Thanks man.. Now it is telling me

'exit status 1
no matching function for call to 'random(int, int, int)'

I HAVE RE-MODIFIED MY CODE SO PLEASE COPY AND PASTE TO SEE WHAT THE PROBLEM IS.. IF YOU CAN

your if command looks wrong

look here : https://www.arduino.cc/en/Reference/If

#include <Servo.h>

Servo myservo1;  // create servo object to control a servo
// twelve servo objects can be created on most boards

Servo myservo2;  // create servo object to control a servo

Servo myservo3;  // create servo object to control a servo

int pos = 0;    // variable to store the servo position

void setup() {
  myservo1.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo2.attach(8);  // attaches the servo on pin 8 to the servo object
  myservo3.attach(7);  // attaches the servo on pin 7 to the servo object
}

void loop() {
int  randNumber = random(1, 3);
  Serial.println(randNumber);
  
  int  del = random(1000,16000);
  Serial.println(randNumber);
  
  delay (del);
  
    if (randNumber == 1){
    // in steps of 1 degree
    myservo1.write(90);
    }
  if (randNumber == 2){
    // in steps of 1 degree
    myservo2.write(90);
    }
 if (randNumber == 3){
    // in steps of 1 degree
    myservo3.write(90);
    }
  
  delay(2000);
      myservo1.write(pos);              // tell servo to go to position in variable 'pos'
      myservo2.write(pos);
      myservo3.write(pos);
      // waits 15ms for the servo to reach the position
  }

a55830:
your if command looks wrong

look here : https://www.arduino.cc/en/Reference/If

#include <Servo.h>

Servo myservo1;  // create servo object to control a servo
// twelve servo objects can be created on most boards

Servo myservo2;  // create servo object to control a servo

Servo myservo3;  // create servo object to control a servo

int pos = 0;    // variable to store the servo position

void setup() {
  myservo1.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo2.attach(8);  // attaches the servo on pin 8 to the servo object
  myservo3.attach(7);  // attaches the servo on pin 7 to the servo object
}

void loop() {
int  randNumber = random(1, 3);
  Serial.println(randNumber);
 
  int  del = random(1000,16000);
  Serial.println(randNumber);
 
  delay (del);
 
    if (randNumber == 1){
    // in steps of 1 degree
    myservo1.write(90);
    }
  if (randNumber == 2){
    // in steps of 1 degree
    myservo2.write(90);
    }
if (randNumber == 3){
    // in steps of 1 degree
    myservo3.write(90);
    }
 
  delay(2000);
      myservo1.write(pos);              // tell servo to go to position in variable ‘pos’
      myservo2.write(pos);
      myservo3.write(pos);
      // waits 15ms for the servo to reach the position
  }

I am basically trying to turn the servo that randomly gets chosen. For example if it is 1… myservo1 moves… if its 3 than myservo3 moves… How can I improve my if command so it does that?

Thank you

look at the code i posted

a55830:
look at the code i posted

Sorry!.. i didnt realize that you made changes. Thank you.

Please use the code tags button </> when you post code

Benny_Leonard:
Thanks man… Now it is telling me

'exit status 1
no matching function for call to ‘random(int, int, int)’

When you get that error you’ll notice that a line is highlighted in pink, that indicates there’s a problem on or near that line:

 int  del = random(1000, 16,000);

So rather than running straight to the forum, take some time to look at your code. If you look closely at that you’ll see you are trying to pass 3 arguments to random(): 1000, 16, and 000. I think what you wanted to do was random(1000, 16000). Always use Tools > Auto Format on your code, that will help bugs such as this to be more clear.

i think i got it working now with 3

look at code copy all of it , servos have been moved to pin 11 , 10 , 9 all pins power managed

#include <Servo.h>

Servo myservo1;  // create servo object to control a servo
Servo myservo2;  // create servo object to control a servo
Servo myservo3;  // create servo object to control a servo

int pos = 10;    // variable to store the servo position

void setup() {
  myservo1.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo2.attach(10);  // attaches the servo on pin 8 to the servo object
  myservo3.attach(11);  // attaches the servo on pin 7 to the servo object
  Serial.begin(9600);
  myservo1.write(pos);              // tell servo to go to position in variable 'pos'
  myservo2.write(pos);
  myservo3.write(pos);
}

void loop() {
  int  randNumber = random(1, 3);
  Serial.print("Servo : ");
  Serial.println(randNumber);

  int  randPos = random(10, 150);
  Serial.print("Random Pos : ");
  Serial.println(randPos);


  int  del = random(1000, 2000);
  Serial.print("delay : ");
  Serial.println(del);

  delay (del);

  if (randNumber == 1) {
    // in steps of 1 degree
    myservo1.write(randPos);
    Serial.println("moving1");
  }
  else if (randNumber == 2) {
    // in steps of 1 degree
    myservo2.write(randPos);
    Serial.println("moving2");
  }
  else {
    myservo3.write(randPos);
    Serial.println("moving3");
  }

  delay(1500);
  myservo1.write(pos);              // tell servo to go to position in variable 'pos'
  myservo2.write(pos);
  myservo3.write(pos);
  
}