Unable to drive two servos simultaneously

I have two MG995 servos connected to a mini arduino-compatible board with a Atmega328p on it.
the problem I am facing is that I cannot move the two servos together!
whenever I do this

servo1.write(40);
servo2.write(40);

the board resets and the servos go crazy!
I have to move the first one the first to 40 degrees then back to 0
then do the same with the other one.
I am powering the servos and the arduino from a 5v dc adapter with max 2A DC load

Power the servos from a pack of four AAs and don't forget to connect the grounds together.

AWOL:
Power the servos from a pack of four AAs and don’t forget to connect the grounds together.

The grounds are connected.
But why to use AA batteries ? the servos are installed inside a device and I am gonna use them almost daily. so I don’t want to keep changing batteries, what is wrong with source I am using or how can I detect if there is a problem?
at first I thought they might need more current but when I checked with an ammeter and they only use 0.2 A max !

Sounds like a brownout causing a reset.
Check the supply with a multi meter when the servos are operating

but when I checked with an ammeter and they only use 0.2 A max !

A meter will not show current spikes.
Try putting a very large capacitor across your supply, something like a 1000uF or bigger.

It would help if you show a diagram of how everything is connected and powered.

The symptom that you mentioned in your original post strongly indicates that the servos are drawing power away from the Arduino.

Whether you use AA batteries or something else to power them, the servos should NOT be drawing their power from the Arduino board.

...R

Attempting to power from an arduino mst often causes the arduino to reset because the servo can draw more power than the arduino can supply. Servos need an external power supply similar to below.

Sorry for the late reply but we got hit by a severe snow storm and had to stop working on my projects.
Anyway this is how everything is connected:


Terminals 1 through 4 are VCC, Ground, digital pin 11 and digital pin 3 respectively.
The servos are MG995.
The 5V is coming from a DC adapter with 1A max.

I got a multimeter with a "fast max" mode that can read current spikes, it showed a maximum reading of 2.1 Amps !!
And Arduino resets then. A single servo draws about 1.7A when it starts and more than 2A when it overshoots. But settles on 0.2~0.3 A.
So yes, it brownout as you mentioned.

I am thinking of replacing the servos with smaller ones.
But until I get them replaced how can I solve this problem?
I believe using two supplies one for Arduino and another for the servos would solve it. but is there a better solution?
Like can I limit the current they are drawing or something similar to that?
(I don't have any large capacitors right now to put across the supply and can you explain how that helps?)
And one more question, if I installed another supply for the Arduino and let the servos operate on the 1A one? is that dangerous? can they damage the supply since they will draw >1A current at some point.

Wouldn't it be simplest to get a 3amp (or bigger) power supply? Or power the whole thing from a suitable battery?

Only time will tell whether the 1 amp power supply would be damaged by excessive current draw from the servos if, as you suggest, the Arduino has a separate supply. I certainly wouldn't leave it unattended in case the power supply went on fire.

A capacitor stores electricity and can release it very quickly if there is a sudden demand. However I doubt if it would have enough capacity to offset the draw from the servos.

In the past I made the below setup that provided 5v to a servo control chip and 5.7v to the servos. The 10uf capacitor and diode provided some brownout protection for the chip.