Running two Servos With Potentiometer

im working with this program http://arduino.cc/en/Tutorial/Knob
This program can only run one servo at a time. is there a way to make it run two seperate servos, each with their own potentiometers?

Yes, just copy the code for reading one pot, and use the output to drive the other servo.
Use the existing code as a template.

Here is some code to try. It is based on the tutorial sketch. The code compiles but I can not test it because I have not received my Arduino from SparkFun yet. Still waiting for the order page to say something other than "Invoice Printed".

// Controlling 2 servos using 2 potentiometers (variable resistor) 
// by Daniel Wright 2010-01-14
// based on the tutorial sketch

#include <Servo.h> 

Servo myservo1;  // create servo object to control the first servo 
Servo myservo2;  // create servo object to control the second servo 

int potpin1 = 0;  // analog pin used to connect the first potentiometer
int val1;    // variable to read the value from the first analog pin 
int potpin2 = 1;  // analog pin used to connect the second potentiometer
int val2;    // variable to read the value from the second analog pin 

void setup() 
{ 
  myservo1.attach(9);  // attaches the first servo on pin 9 to the servo object 
  myservo2.attach(11);  // attaches the second servo on pin 11 to the servo object 
} 

void loop() 
{ 
  val1 = analogRead(potpin1);            // reads the value of the first potentiometer (value between 0 and 1023) 
  val1 = map(val1, 0, 1023, 0, 179);     // scale it to use it with the first servo (value between 0 and 180) 
  myservo1.write(val1);                  // sets the first servos position according to the scaled value 
  delay(15);                           // waits for the first servo to get there 
//  
  val2 = analogRead(potpin2);            // reads the value of the second potentiometer (value between 0 and 1023) 
  val2 = map(val2, 0, 1023, 0, 179);     // scale it to use it with the second servo (value between 0 and 180) 
  myservo2.write(val2);                  // sets the second servos position according to the scaled value 
  delay(15);                           // waits for the second servo to get there 
}

Hope this helps.

Dan

2 potentiometers (variable resistor)

Being terribly picky, I'd say that a variable resistor (two terminals) is not necessarily a potentiometer (three terminals). :wink:

'N' servo solution (untested, uncompiled, come to that!)

#include <Servo.h>
#define N_SERVOS 2
Servo myservos [N_SERVOS];
const int potPins [N_SERVOS]   = {0, 1};
const int servoPins [N_SERVOS] = {9, 11};

void setup()
{
  for (int i = 0; i < N_SERVOS; ++i) {
    myservo[i].attach(servoPins [i]);
  }
}

void loop()
{
  for (int i = 0; i < N_SERVOS; ++i) {
      myservo[i].write(map(analogRead (potPin [i]), 0, 1023, 0, 180));  
      delay(15); // waits for the servo to get there
  }
}