arduino uno resets randomly while executing the code on a quadropod robot

So i made this quadruped robot and the code, whenever executed, starts and sometimes ends when the robot is not touching any surface like if i hold it it will sometimes do just fine and at other times restart the sequence. Whenever its on the ground however it will restart immediately after the sequence starts. Its like the servos have a timer set or whtver but it doesn't seem to be the case please help.

spider_open_v3.ino (22 KB)

It’s the problem of your power supply. When there’s load on servo, the current draw will be larger than moving in the air. Your battery will experience a voltage drop and cause the control board to restart.

RzLi:
It’s the problem of your power supply. When there’s load on servo, the current draw will be larger than moving in the air. Your battery will experience a voltage drop and cause the control board to restart.

do you have a solution to this

Use batteries with higher discharge rate. Search for “high c rated LiPo battery”. Make sure the voltage regulator also support the high current. Add a capacitor in parallel with servos will help too. I also suggest you to separate power supply for control and motion.

To easily validate my assumption, you can double the power supply in parallel configuration to double the current allowed.

I also made a quadruped in cat shape. I’m going to post it on project hub recently.

Show us a wiring diagram. Pencil, paper and a camera are good enough if you provide proper detail.

darius_foodeei:
do you have a solution to this

Yes. You tell us what you are currently using to power the system and how it is wired. Then we can tell you what would be better.

Steve

As other's have mentioned, it sounds like it may be a problem with power. How are you powering the motor controllers? Never rely on the +5V regulator of the arduino to go past 500mAh, without browning out. (drawing more than the regulator can provide, result shuts-down, and causes a full reset). are they being powered by a separate regulator? are the prop motors drawing enough amperage trying to get up to speed, that they're drawing more amperage, it may not even have enough to handle the arduino as well (not a likely, but still possible, the arduino has a rather lite diet.)