Hello. I have 12 nanos each one drive a servo (SG996) with basically sweep's example. They are powered all together with 5V 5A power switch. Sometimes one or two servos stop working. If I turn off and on again, they will start. What's the problem?
The servo power supply should be rated for 1 Ampere per (small) SG90 servo, 2.5 Ampere per (large) MG996R servo, minimum.
So the power supply should be rated for 12 to 30 Amperes, minimum, for 12 servos.
Please post a link to the data sheet or product page for servo you actually have.
Running 2 - 5 servos it would be okey.
Edit: Regard reply #2 by @jremington
Or don't move them all simultaneously. Move one, shut it off, move the next one, shut it off.
Hello lorant0
Post your sketch, well formated, with well-tempered comments and in so called code tags "</>" and schematic to see how we can help.
Have a nice day and enjoy coding in C++.
Hi, @lorant0
Welcome to the forum.
Can you post some images of your project so we can see your component layout?
Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.
Thanks.. Tom..
![]()
My nano are some simple animatronics. They are some birds made with umbrella parts. Servo will fold and unfold while they are powered. I need a random begin delay and a random delay into for loop for create diversity betwwen each birds.
// initial delay
#define initDelayMinVal 2000
#define initDelayMaxVal 2800
bool DEBUG = 0;
#define wingMinVal 35 //30
#define wingMaxVal 150 //170
#define SERVOPIN 3
#include <Servo.h>
Servo servoali;
// int delayLoopVal = 15; //init
#define delayLoopMinVal 10
#define delayLoopMaxVal 15
void setup() {
digitalWrite(LED_BUILTIN, LOW);
servoali.attach(SERVOPIN); // attaches the servo on pin SERVOPIN to the servo object
if (DEBUG) (Serial.begin(9600));
// close wings - hibernation mode
servoali.write(wingMinVal);
randomSeed(analogRead(0));
delay(random(initDelayMinVal, initDelayMaxVal)); // need it for give diversity
}
void loop() {
int delayLoopVal = random(delayLoopMaxVal - delayLoopMinVal + 1) + delayLoopMinVal; // need it for give diversity
if (DEBUG) (Serial.println("delayLoopVal =" + String(delayLoopVal)));
int pos = random (delayLoopMinVal, delayLoopMaxVal); // default 15 - It provides more movement diversity. It executes each new fold-unfold cycle with a different speed
for (int pos = wingMinVal; pos <= wingMaxVal; pos += 1) { // goes from wingMinVal degrees to wingMaxVal degrees in steps of 1 degree
if (DEBUG) (Serial.println("pos =" + String(pos)));
servoali.write(pos); // tell servo to go to position in variable 'pos'
digitalWrite(LED_BUILTIN, HIGH);
delay(delayLoopVal); // waits delayLoopVal ms for the servo to reach the position
digitalWrite(LED_BUILTIN, LOW);
}
if (DEBUG) (Serial.println("== END WING UNFOLD =="));
for (pos = wingMaxVal; pos >= wingMinVal; pos -= 1) { // goes from wingMaxVal degrees to wingMinVal degrees
digitalWrite(LED_BUILTIN, HIGH);
if (DEBUG) (Serial.println("pos =" + String(pos)));
servoali.write(pos); // tell servo to go to position in variable 'pos'
delay(delayLoopVal); // waits delayLoopVal ms for the servo to reach the position
digitalWrite(LED_BUILTIN, LOW);
}
if (DEBUG) (Serial.println("== END WING FOLD == "));
}
Servos are diymore MG996. I didn't find official datasheet but I think are equal to DM996R.
Into the shop page I can read:
- Operating Voltage 4.8V-6.0V
- No Load Speed 0.18sec/60°(4.8V),0.15sec/60°(6V)
- Running Current 160mA(4.8V),170mA(6V)
- Peak Stall Torque 9kg.cm(4.8V),13kg.cm(6V)
- Stall Current 1100mA±10%(4.8V),1300mA±10%(6V)
- Command Signal Pulse Width Modification
- Amplifier Type Analog Controller
- Pulse Width Range 500~2500usec
- Neutral Position 1500usec
- Running Degree 180°±3°(when 500~2500usec)
- Dead Band Width 8 usec
- Rotating Direction Counterclockwise (when 1000 ~ 2000usec)
That being said, I would say you're right ![]()
I have also a 5V 30A and 5V 40A. I had seen that it appeared to work at 5A and had ruled out the need for more amperage.
If you power all 12 Nanos at the same time and they all attach their servo at the same time, what will the current draw be? 12 times 1.1 Amps = 13.2.
Hello lorant0
Do you have experience with programming in C++?
This task can easily be realised with OOP.
A structured array contains all the information, such as the pin addresses for the I/O devices, as well as the information for the timing and device driver used.
A single service takes care of this information and initiates the intended action.
The structured array makes the sketch scalable until all I/O pins are used up without having to adapt the code for the service.
It is cool stuff, isn´t it?
Have a nice day and enjoy coding in C++.
You are right! Why it "works" with 5V 5A...?
try to put all printing in some function apart from main program as it is done in a buffer and when you write to fast it will overflow, and you can use more as one in a nano (name them servo1 servo 2 etc. also check your program for variables that are lost or and an if () should be followede by {} and not (). make also a start with one foldin and unfolding so they do start all same way.
you use pin 3 however in the comment it says 9
I can't plug more than 1 servo for every nano. I fixed pin definition into comments
Hello lorant0
The servo libary provides the handling of 12 servos to same time.
ok! I can't plug in all servo into one Nano because they must stay apart.
what is this ?
That setting is used to provide more movement diversity. It executes each new fold-unfold cycle with a different speed (applying a delay to each new servo.write between 10 and 15 millis)
I solved using a 5V 40A switching power supply.
You will need to fit fuses to each Nano circuit and a main fuse to the output of the 40A power supply.
If you have a short anywhere in your project, the power supply will try to put 40A through it.
This is enough to basically blow your Nano's, or servo's and or wiring to the gods.
Tom....
![]()

