Hello. I connected the mg995 servo to the Arduino board. When I upload this code, instead of the servo being in the 180 position, it continues to rotate and does not stop. Can anyone help me?
If it rotates all the way round then you have a continuous rotation servo. If you write 90 it should stop. Values lower make it go one way and higher make it go the other way.
What you have is an electronically controlled motor whose position you cannot control, only its speed and direction. It just happens to be in a servo case
You should also be cautious about powering it from the Arduino as it may take more current than the Arduino can provide when starting or stalled
No real servo does continuous rotation. Many unscrupulous distributors do not differentiate between the two types and you cannot tell from the model number which type it is
Servos for use in model aircraft and helicopters are always proper servos
Look at this one
It is a servo, but if you just buy one online it could be either type, so read what the web page says very carefully and check with the seller if necessary
Did you understand my warning about powering a servo from the Arduino ?
For instance, on the page that I linked to look at the stall current
Current draw at idle 10MA
No load operating current draw 170MA
Stall current draw 1200MA