Using more servos issue with ATMEGA168-20PU microcontroller

Hi Folks,

I'd like to use more (4 servos) in the same time. Everything's working fine when I connect my servos to my Arduio Mega board, but when I upload my sketch to the chip the servos just tremble and do not sweep. However if I connect only one servo the sketch is working like a charm and the servos are sweeping. I powered my ATMEGA chip and the servos from my Arduino board. I cannot find out what could be the problem please help me it is driving me crazy...

Many thanks!

Here's my very simple code:

#include <Servo.h>

Servo servo1; 

Servo servo2;

Servo servo3;

Servo servo4;

int i = 0;


void setup() {

  servo1.attach(3);

  servo2.attach(5); 

  servo3.attach(6); 

  servo4.attach(9); 

}

void loop() {

  for (i = 0; i < 180; i++) { 

    servo1.write(i);              

    servo2.write(i);     

    servo3.write(i);

    servo4.write(i);         

    delay(10);                      

  }

  for (i = 180; i > 0; i--) { 

    servo1.write(i);                

    servo2.write(i);     

    servo3.write(i);

    servo4.write(i);          

    delay(10);                      

  }

}

Welcome to the forum

That is generally not a good idea. The Arduino is not intended to be used as a power supply. Consider using a separate power supply for the servos

How is the project powered ?
Is the board resetting ?

Thanks for your answer.

"How is the project powered ?" -> my Arduino board? I'm powering from my PC with USB cable.
"Is the board resetting ?" -> what do you mean resetting?

I don't understand why it's working with arduino and don't working on the chip. Same power or I'm wrong?

I mean starting again as if you had pressed the reset button

Put a print statement in setup() and run the sketch with the Serial monitor open. How many times do you see the message ?

Oh..ok I'll try...

For servos you need a separate 4.8-6V power supply, capable of providing at least 1 Ampere per small servo, 2.5 A/servo for larger ones like the MG996R.

A 4xAA battery pack will work for 1 or 2 of the small SG90 servos. Don't forget to connect all the grounds.

OK. Thank you for your answer.

OK. Thank you for your answer. So for example if I want use 4 servos I need a 5V/5A adapter to power all the four servos right?

As mentioned, that depends on the type of servo you have.

I'm using SG90 servos.

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