I want to interface multiple servo with arduino nano,i tried the following code but the motors didnt move.
I used 5v/12A power supply.
#include <Servo.h>
Servo f1; Servo f2;
Servo f3; Servo f3; Servo f5
;
int potpin = A0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup() {
f1.attach(9); f2.attach(3);f3.attach(5);
f4.attach(6);f5.attach(10);
}
void loop() {
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180); // scale it for use with the servo (value between 0 and 180)
f1.write(val);f2.write(val);f3.write(val);
f4.write(val);f5.write(val);
delay(15);
}
Assuming a compiled version of the sketch, and in the absence of a wiring diagram, I'm going to guess that the power supply you mention is to the Arduino and that the servos are powered from the latter.
Or have you connected that power direct to the servos, which is the correct way? And connect the power -ve to the Arduino ground as well. (If you don't then the servo control wire (the yellow or orange one, sometimes white) has no 0 to be measured against.)