Guys, I found a solution to the twitching servos.
It's simple: servos are made of their circuitry, which consumes only a small amount of current, and their motors, which need serious currents to move.
In your design, you have to implement a high-side switch made with a switching NPN transistor to receive the signal from the Arduino (through a resistor, of course) and a MOSFET, to handle the high current to the servo. The collector of the NPN goes to 5V through a resistor, and the emitter goes to the ground.
The MOSFET gate has to be wired to the NPN's collector, directly, at the junction between the collector and the resistor. The Source pin of the MOSFET goes to the same 5V and Drain goes to the servo's +.
VERY IMPORTANT: in parallel with the servo(s) put a 2200uF electrolytic capacitor.
Between Source and Drain put a resistor to fuel the capacitor while the circuit is shut off. You may not need to, I did, it depends on how many servos you have. Alternatively, you can put a bigger capacitor.
In your sketch, do this:
- assuming A2 is the pin you assigned for controlling the electronic switch you just built.
- #1: digitalWrite(A2, 1);
That's all. Now, the explanation, for those who didn't get it yet:
1: the first digitalWrite sends power to the servo and fills the capacitor in the shortest amount of time.
2: Before the servo can have enough power to move its motor, you shut off power to it, so all that it has available is what's stored in the capacitor, so the servo's "brain" is now active, but can't twitch, as it doesn't have enough power.
3: Now, before the capacitor depletes and the servo is left out of conscience (and twitches to subsequent power-ons), you reapply power with line #3. As a result, it won't twitch anymore.
This works 100%.
If it doesn't, or you don't know how to do the circuit, you can buy a ready-made high-side power switch and do it with that. The capacitor is the most important in this equation.
And, don't forget to visit my site, www.greenoptimistic.com.