Servo MG995 and arduino board

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?

#include <Servo.h>
Servo servo1;

void setup() {
servo1.attach(9);
servo1.write(180);
}

void loop() {
}

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.

1 Like

You don't have a servo.

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

1 Like

Can you suggest me a servo with the same power? So that I can determine its position?

Can you suggest me a servo with the same power 13KW?

13KW would be a hell of a servo !

If you are happy with the size and power pf the mg995 then buy a genuine one that is not a continuous rotation "servo" such as an MG995 – Tower Pro

1 Like

And how about MG945? is it a continuous rotation servo or not?

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

1 Like

How do you think I can change my code to use this MG995 servo? For example, what code should I write to be in a position of 180 degrees?

You cannot use your "servo" to control its angle unless you add more hardware to it to provide feedback to the Arduino.

1 Like

I use HCPCA9685.Is it suitable?

How many servos are you controlling?

18 Servos

Sorry, I have never used that library.

Yes, it is suitable for use with servos and allows them to be powered easily from an external power supply.

Note that it will not solve your problem with the servo being the wrong type and to control 18 servos you will need two HPCA9685 boards

Thank you very much for helping.

I read somewhere that all 180 degrees servos are not continuous rotation servos. is it right?

Normal servos are 180deg and they are not continuous rotation.

1 Like

All of them?

If a servo can only rotate less than 360 degrees it cannot be a continuous rotation servo, can it ?

1 Like