Arduino Crashes while using hobby servos Sg90

Parts: 4 Hobby Servos “SG90”, 2 Joystick Modules, and 1 Arduino genuino uno.

We also used this kit at: http://www.instructables.com/id/EEZYbotARM/

When we Use the 4 hobby servos to control this robotic arm, the arduino board will crash and run the code again from the start. We know this because the board’s light shuts down, and will run the setup code again when it turns back on. We think it is not a power issue. Even when we do not use the servos, if we wait long enough it will crash and reset anyway.

#include <Servo.h>
Servo Rotation;
Servo UpDown;
Servo InOut;
Servo Close;
int DeadZone[] {515, 518, 522, 523}; // Relative Midpoint of All Axis From LX, LY, RX, RY
int ServoArray[] = {9, 10, 11, 12};
int ServoPos[] = {90, 90, 90, 90};
int JoystickPos[] = {A5, A4, A3, A2, 13}; //{LY,LX,RY,RX,RPW};
int JoystickL[] = {0, 0}; // Vector2, X and Y
int JoystickR[] = {0, 0}; // Vector2, X and Y
int JoystickMapL[] = {90, 90}; // Vector2, X and Y
int JoystickMapR[] = {90, 90}; // Vector2, X and Y+
void setup() {
  /*Attach and write all servos to default pos */
  Rotation.attach(ServoArray[0]);
  UpDown.attach(ServoArray[1]);
  InOut.attach(ServoArray[2]);
  Close.attach(ServoArray[3]);
  Rotation.write(ServoPos[0]);
  UpDown.write(ServoPos[1]);
  InOut.write(ServoPos[2]);
  Close.write(ServoPos[3]);
}
void loop() {
  
  JoystickL[0] = analogRead(JoystickPos[0]);
  JoystickL[1] = analogRead(JoystickPos[1]);
  JoystickR[0] = analogRead(JoystickPos[3]);
  JoystickR[1] = analogRead(JoystickPos[2]);
  
  /*Read Joysticks and Create a new "Map" var to convert 0-1024 to 0-180 */
  
  JoystickMapL[0] = map(JoystickL[0], 1024, 0, 0, 180);
  UpDown.write(JoystickMapL[0]);
  //UpDown
  JoystickMapR[0] = map(JoystickR[0], 0, 1024, 10, 180);
  InOut.write(JoystickMapR[0]);
  //InOut
  JoystickMapR[1] = map(JoystickR[1], 0, 1024, 10, 140);
  Close.write(JoystickMapR[1]);
  //Close
  JoystickMapL[1] = map(JoystickL[1], 0, 1024, 0, 170);
  Rotation.write(JoystickMapL[1]);]
  
  /* Write all servos to converted 1024 - 180 Map pos*/
  
  delay(10);
}

The links are a bit long... So how is it powered? The Arduino can't deliver the power for a single Servo, let along 4 :)

I think it is precisely a power issue. Trying to power 4 servos from the Arduino 5V pin was never going to work.

Connect the servos to a separate power supply or battery (preferably rechargeable, 4 x AA would probably do). Then see how much better it works.

Steve

lmcfadden18: Parts: 4 Hobby Servos "SG90", 2 Joystick Modules, and 1 Arduino genuino uno.

We also used this kit at: http://www.instructables.com/id/EEZYbotARM/

When we Use the 4 hobby servos to control this robotic arm, the arduino board will crash and run the code again from the start. We know this because the board's light shuts down, and will run the setup code again when it turns back on. We think it is not a power issue. Even when we do not use the servos, if we wait long enough it will crash and reset anyway.

Where did you come up with the idea to drive 4 servos from 1 Arduino ?

That webpage you linked doesn't even begin to talk about that.

I quote from the author "The way to drive the servo are several. I tried them pretty all. To explain it will take to much and this instructable is big enough ..... probably I'll make a new instructables dedicated, If I get time. Anyway if you want to explore there are quite enough material around the web. "

Useless!

NEVER power a servo from the Arduino.

Use a separate servo power supply, capable of supplying 1 Ampere per servo. Connect the grounds.

Avoid Instructables like a disease.

Hmmm…
This image from the instructable page clearly shows external power being applied to the servos.

InstructablesImage.jpg

Is that how you have your servos powered?

The Op's circuit diagram clearly shows them all powered from the Arduino 5V pin....but I suppose it might be lying.

Steve

Servos contain motors, motors require real power(*), way beyond what sensors and microcontrollers use.

(*) many watts peak.