Servo power and common ground
Keep your board stable by separating motor power and sharing the signal reference.
A servo uses three connections: supply, ground and a control signal. The control signal requests a position; it does not provide motor power. Typical SG90 colours are red supply, brown ground and orange signal, but always verify your unit.
A servo can draw a large current when starting or stalled. Supplying it through the Arduino board can cause voltage dips, USB disconnects or resets. For one unloaded SG90, start with a regulated 5V supply rated at least 1A and use short power leads. Clones and mechanical loads can require more current.
Connect the external supply ground to the servo ground and the UNO ground so the signal has a shared reference. With the UNO powered by USB, keep the external +5V connected only to the servo supply. Do not tie competing regulated supplies together.
Connect the signal to UNO D9 and use the official Servo library. Start at 90 degrees with the horn unloaded. Use a conservative 20-to-160-degree sweep, reducing the range if the mechanism reaches a stop. Disconnect power immediately if the servo stalls or heats excessively.
If the board resets, inspect the supply rating, ground wiring and cable resistance. Never force a powered servo by hand. The SG90 Servo Sweep project includes a complete example and identifies the extra power supply needed.
Reference: https://docs.arduino.cc/learn/electronics/servo-motors/
