Unstable when using battery
Multiple supplies and/or voltage regulators are often needed with servos and motors in general, but it is easy to get confused about how to choose them and link them together. I am sorry if you are short of time, etc. and disappointed, but without a circuit diagram, trying to figure out what you actually have is more random than shooting in the dark, and only likely to cause more endless confusion and frustration.
I don't know if the newcomer forum rules allow you to paste in a diagram yet, but either way, if you make a few more postings, you should soon get full access - I don't know what the exact threshold count is .. maybe 5 or 6? ... it is not a vast quantity, so please keep in touch.
Best wishes, Dave
@davee @mikel It's 10. I blame myself for this, I totally forgot the servo motor needs its own power supply. The OP was obviously powering both the motor and the logic with one power supply and I didn't catch that.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.