Interfacing multiple servo problem

Hi,

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);                           
}

Could anyone help me

The sketch that you posted does not compile because of a redefinition of Servo f3

Are you sure that you posted the correct sketch

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.)

Hi,
Can you please post a schematic of your project please?
I assume you have the servo power supply gnd connected to the Nano gnd?

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

Thank you all

I tried the following two circuits ,,

Sorry for draw the schematics by hand, iam posting from mobile ^^

Hi,
Have you tried the example code that comes with the library for JUST one servo?
Try code for one servo only.

What value is your pot?

Tom... :smiley: :+1: :coffee: :australia:

Yes , it worked

I used 10k pot

I tried alot of suggestions but the problem still exists.

Finally I replaced the nano with arduino uno,the motor worked

Thank you all

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.