Controlling two servos with two potentiometers simultaneously

robtillaart:
Think you need to slow it down a little, so a longer delay. Furthermore add some debug statements what values are read.

It can also be a matter of power, if you unhook one servo does the other start working?

// Ketto szervo helyzetet vezerli potenciometerrel (valtoztathato ellenallas) 

// 2012, Copyright Santa Krisztian

#include <Servo.h>

Servo szervo1;  // szervo1 objektum letrehozasa az egyik szervo vezerlesehez
Servo szervo2;  // szervo2 objektum letrehozasa a masik szervo vezerlesehez

int potpin1 = 2;  // analog lab csatlakozik az egyik potenciometerhez
int potpin2 = 5;  // analog lab csatlakozik a masik potenciometerhez

int val1;    // valtozo, amely olvassa az egyik analog lab erteket
int val2;    // valtozo, amely olvassa a masik analog lab erteket

void setup()
{
 Serial.begin(115200);
 szervo1.attach(9);  // az egyik szervot csatolja a 9-es labon a szervo1 objektumhoz
 szervo2.attach(11);  // az egyik szervot csatolja a 3-as labon a szervo2 objektumhoz
}

void loop()
{
 val1 = analogRead(potpin1);            
 val1 = map(val1, 0, 1023, 0, 179);    
 szervo1.write(val1);        
 Serial.print("Val1 = ");
 Serial.println(val1);
                               
 
 val2 = analogRead(potpin2);            
 val2 = map(val2, 0, 1023, 0, 179);    
 szervo2.write(val2);  
 Serial.print("Val2 = ");
 Serial.println(val2);              
 delay(200);                          
}

Indeed, the 'delay(200)' did it to works, although with slow motion.

So I have now a "robot arm" with two servos that I can control with two potentiometers.

Before I uploaded this code abowe, I tried advices and yes, if I unhooked one servo the other started working.

The problem is solved (thank you very much!!), however, how can I read the added debug statements what values are read is?

Regards, from Pál