Arduino resets itself when connect 2 micro servos

Hello guys, I made a robot and a robotic arm with only 2 micro servos one to move the Y axis one to move the gripper that will hold items and I also made an app with MIT app inventor to control the robot and the robotic arm. The problem :
when the servos move the arduino and the app I made freeze. I know I can connect power supply for the servos. But they are only 2. Iam supposed to connect power supply only when I have 4 micro servos or more right ?

Thanks.

Hi,
Nope, even 2 servos will be enough to cause problems with the Arduino power supply.

A separate supply with gnds of the supply and the Arduino joined will give you the proper servo stability.

Tom... :slight_smile:

Tried that.. But when the servos move for at least half a minute the app crashes.

One motor works find and the other is not working and when I move them everything crashes

You say 'Tried that' but it still sounds like a power problem.

Show us how you have things wired up. A pencil, paper and a camera is good enough if you show the proper detail.

How is the arduino powered? How are the servos powered?

Ok just 2 hours and I will be back sorry.

Just in case you doubt how much current even a micro servo can draw, look here. (The page title says mini servo I know, but the photo says micro.) At stall even that tiny servo can draw almost 3/4A.

edit: Interestingly, if you do the sums given a torque of 1.8kgcm and a speed of 0.1s/60°, that's power of almost 2W. At 5V that's 0.36A, so if the makers say it's going to draw twice that, that's the inefficiency between the mechanical power it outputs vs the electrical power it consumes.

The wiring : (note: there might be mistakes with the fritzing diagram.)
Wiring Diagram

kenwood120s:
Just in case you doubt how much current even a micro servo can draw, look here. (The page title says mini servo I know, but the photo says micro.) At stall even that tiny servo can draw almost 3/4A.

edit: Interestingly, if you do the sums given a torque of 1.8kgcm and a speed of 0.1s/60°, that's power of almost 2W. At 5V that's 0.36A, so if the makers say it's going to draw twice that, that's the inefficiency between the mechanical power it outputs vs the electrical power it consumes.

Thanks for the info, but how to fix my problem ?

OPs image

How is the arduino powered in this setup?

Are the servos unloaded? Or are the already in your robot arm?

The arduino is powered with 3 ultrafire batteries.
The servos are in my robotic arm.

Note :
if this will be helpful my robot consists of :
4x 6v dc gear motor controlled with 2x L293D and there is an LCD to display the temperature (LM35)
And an LDR and 3 leds to light in dark and also 2 speakers and 1 sd card module to read the WAV files from the sd card and play them with the speaker And finally an HC-05 bluetooth module to control the robot movements and the robotic arm (I made the application with MIT app inventor)

Circuit looks reasonable - have you checked the servo supply is not dropping out?
And where's the code?

Are you sure your battery can supply enough current? 4A is plenty- not perhaps confusing 4Ah capacity with 4A current?

Hardizzer:
The arduino is powered with 3 ultrafire batteries.
The servos are in my robotic arm.

Note :
if this will be helpful my robot consists of :
4x 6v dc gear motor controlled with 2x L293D and there is an LCD to display the temperature (LM35)
And an LDR and 3 leds to light in dark and also 2 speakers and 1 sd card module to read the WAV files from the sd card and play them with the speaker And finally an HC-05 bluetooth module to control the robot movements and the robotic arm (I made the application with MIT app inventor)

Are all those extra components hooked up yet?

Yes, I have 3 ultrafire batteries for powering arduino, 3 more ultrafire batteries for powering the 4x dc gear motor.

MarkT:
Circuit looks reasonable - have you checked the servo supply is not dropping out?

Idk, how to check ? I'am still newbie in electronics.
Code and app blocks are from this link: (note: the blocks and code are made for 10 motors but I edited them)

And the edited version of arduino code :

#include <Servo.h> 
Servo myservo1, myservo2;

byte serialA;

void setup()
{
  myservo1.attach(A8);
  myservo2.attach(A9);
  myservo2.write(180);
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available() > 2) {
    serialA = Serial.read();
    Serial.println(serialA);
    unsigned int servopos = Serial.read();
    unsigned int servopos1 = Serial.read();
    unsigned int realservo = (servopos1 *256) + servopos; 
    Serial.println(realservo); 
    
    if (realservo >= 1000 && realservo <1180){
    int servo1 = realservo;
    servo1 = map(servo1, 1000,1060,0,60);
    myservo1.write(servo1);
    Serial.println("servo 1 ON");
    delay(15);

    }
    
    if (realservo >=2000 && realservo <2180){
      int servo2 = realservo;
      servo2 = map(servo2,2000,2180,0,180);
      myservo2.write(servo2);
      Serial.println("servo 2 On");
      delay(15);
    }
  }
}

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

TomGeorge:
Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

I know how to do it. but when I was copying the code I was in the Quick Reply it doesnt contain the add code button

Any help ??

Does it work if you disconnect one of the servos? Because as others have said, it looks like a power issue. Some more prints would be helpful though - what are you sending to the arduino? Are you sending CR & LF and confusing your read routine?

Hardizzer:
I know how to do it. but when I was copying the code I was in the Quick Reply it doesnt contain the add code button

You have to use the Reply not Quick Reply.

Or you can type the

[code] your code here [/code]

tags front and back of the code