Servos keep moving!?

Hi, I have a code for a rocket’s avionic system. The system includes MPU6050, BMP180, NEO6M GPS, servo motors (two of them) etc. It should take actions in certain conditions, such as making servos turn. The problem is that when I upload and run the code, even though the conditions to run the servos are not present, the servos start waving their hands and seeing me off. They move right and left at certain intervals. I could not understand the reason why they do so. I’m attaching the code, and waiting for your help. Thank you :slight_smile:

main_program_woex.ino (5.05 KB)

That behavior is almost always due to an inadequate servo power supply. Posts like yours come up almost every day on the forum, usually because people follow bad advice on the web.

Do NOT try to power servos or motors from the Arduino 5V output. Use 4xAA cells instead, and connect the grounds.

jremington:
That behavior is almost always due to an inadequate servo power supply. Posts like yours come up almost every day on the forum, usually because people follow bad advice on the web.

Do NOT try to power servos or motors from the Arduino 5V output. Use 4xAA cells instead, and connect the grounds.

I will give it a try quickly! Thank you