servo and potentiometer

hello every body i am working on two servos and i wanted to power both using one potentiometer , I wrote a code to control one servo using the stament if if(sensorValue>400) then power servo and it works fine but i wanted to power two servos with statment if(300<sensorValue<400) power fırst servo and if(600<sensorValue<800) power the second servo , here ı attached the code and the schematic . any help please , thanks in advance

#include <Servo.h>

Servo MoYu;
int counter = 0 ;
void setup ()
{
Serial.begin(9600);
MoYu.attach(9);
}
void loop ()
{
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(300);
if(sensorValue>400)
{
for (counter = 0 ; counter>=180;counter +=1)
{

MoYu.write(counter);
delay (5);
}
for (counter = 180 ; counter>=0;counter -=1)
{
MoYu.write(counter);
delay (5);
}
}
}

moyu.ino (430 Bytes)

hello every body i am working on two servos and i wanted to power both using one potentiometer

And control them using a battery? Potentiometers are not used to power servos. They can be used to control servos. Batteries are used to power servos.

but i wanted to power two servos with statment if(300<sensorValue<400)

That is NOT how, in C, you determine that a value is in a range. There are no shortcuts.

if(sensorValue > 300 && sensorValue < 400)
if(300<sensorValue<400)

The correct syntax to check a range of values is

if(sensorValue > 300 && sensorValue < 400)

Incidentally you are not powering the servos rather you are controlling them but I would be interested to know where they do get their power from as the Arduino probably cannot supply enough current to drive 2 servos.

thank you Mr PaulS for your quick comment every body know that the potentiometer is used to control not as power supply and if you check the schematic i attached you will understand my question . thank you for your quick reply

thank you Mr UKHeliBob how can i control more than servo

how can i control more than servo

read value from pot
if value is in range A
write to servoA
else if value is in range B
write to servo B