Servo spinning around or not working when I use Myservo1.write(angle);

Hi I am trying to use program servo. I am newbie. I have connected brown wire from servo to GND on arduino, red wire on servo to 5V on arduino and yellow vire to pin n. 8. I use the MG90S servo. The servo spin around or when I change value for example to 90 it just dont spin. Please help me.

#include <Wire.h>

#include <Servo.h>
Servo Myservo1;
void setup() {
  Serial.begin(9600);
  Myservo1.attach(8);

}

void loop() {
  Myservo1.write(0);

}
1 Like

It sounds like you have a continuous rotation "servo", ie not really a servo at all

If so then you cannot control its angle, only its speed and direction of rotation

So I couldnt rotate mg90s to specific angle?

Yes you can rotate the mg90 to a specific angle.

Consider for a moment the above statement. Why did the servo stop spinning? It went to 90 and stayed. All the code is telling the servo to go to is 90.

Have you ran servo sweep, located in your examples?

yes i ran the sweep it spin for som time around then it change direction

You may find that the servo does not work se well at 0 degrees and at 180. You'll have to work out the range of the servo operations by

Does it work right? No.

`Myservo1.write(1); No?

`Myservo1.write(2); No?

and so on and so forth till you find the minimum value that your servo responds to. Then do the same with 180. `

And don't forget post #2.

Try a value of 45. If it spins forever, you can't set a position. If it stops, you can.

Double check servo wires are the correct colour for the function.
I do model aircraft flying and sometime you get servos that have different function colours.
So double check for make/model of your servo. Also servos can pull lot of current and cause voltage spikes that can upset the program so big cap say 10,000uf across the gnd to vcc may help

Hi I just found the maximum for 0 and 180 but how can i set it to specific angle

You can't

You can stop it by writing a value of 90, but you can't tell it where to stop

Well if you cannot do

If that does not send the servo to 50 degrees and it stops then you need see post #2 and post#10.

Could you a image of your setup?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.