servos

how do i make 2 servos do two different things on the same board

how do i make 2 servos do two different things on the same board

Like one should sing while the other dances?

To make two servos do different things, write different code for each one.

how do i make 2 servos do two different things on the same board

Like one should sing while the other dances? [/quote]

LOL!! :D

how do i wright the code for each one

The same as you write code for just one, but do it twice, but a bit different.
If you posted the code you’ve already got, we could help you modify it.

#include <Servo.h> //include the servo libary

Servo myservo;  // create servo object to control a servo
// a maximum of eight servo objects can be created

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

void setup()
{
myservo.attach(9);  // i want 3 servos to operate 


                                    // attaches the servo on pin 9 to the servo object
randomSeed(analogRead(A0));
}

void loop()
{
for(pos = 15; pos < 90; pos += 90)  // interverls
{                                  
myservo.write(pos);              // tell servo to go to position in variable ‘pos’
delay(random(0,3000));                       
}
for(pos = 90; pos>=15; pos-=90)     // max rotation
{
myservo.write(pos);              // tell servo to go to position in variable ‘pos’
delay(random(3000,0));                      
}
}

And what do you want to add?

i want 3 servos to randomly turn 90 degrees. stay turned for 3 seconds then go back to 15. but the servos need to be random on there own. but only one servo turns at a time

Ok, scrap the delay()s, and have a look at the blink without delay example. Substitute servo movements for LED operations

i have no clue how to do that

So forget the servos, and just concentrate on the blink without delay example. If you haven't got a LED, just put in some serial prints. This is an essential skill, so take your time to really understand how it works.

how about you fix my code so my brain doesnt melt

can someone help me. i want a servo to (at a random time) rotate 90 degrees but only return to 0 by a push of a button

some servo/button test code

//zoomkat servo button test 12-29-2011

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(170);
  }    
  
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    servo1.write(10);
  }
  
  /*else {
    servo1.write(90);
  }*/
}

test code with two servos

// zoomkat 12-13-11 serial servo (2) test
// for writeMicroseconds, use a value like 1500
// for IDE 1.0
// Powering a servo from the arduino usually DOES NOT WORK.
// two servo setup with two servo commands
// send eight character string like 15001500 or 14501550
// use serial monitor to test

#include <Servo.h> 
String readString, servo1, servo2;
Servo myservo1;  // create servo object to control a servo 
Servo myservo2;

void setup() {
  Serial.begin(9600);
  myservo1.attach(6);  //the pin for the servo control 
  myservo2.attach(7);
  Serial.println("two-servo-test-1.0"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(3);  //delay to allow buffer to fill 
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    } 
  }

  if (readString.length() >0) {
      Serial.println(readString); //see what was received
      
      // expect a string like 07002100 containing the two servo positions      
      servo1 = readString.substring(0, 4); //get the first four characters
      servo2 = readString.substring(4, 8); //get the next four characters 
      
      Serial.println(servo1);  //print to serial monitor to see results
      Serial.println(servo2);

      int n1 = servo1.toInt();
      int n2 = servo2.toInt();
      
      myservo1.writeMicroseconds(n1); //set servo position 
      myservo2.writeMicroseconds(n2);
    readString="";
  } 
}

what would *else represent

@OP: Please stop asking the same question in different threads - it wastes everyone's time. I've merged them up so that you can see all the answers in one place.