MG966R Servo Motor 360 degree continuous rotation problem

Hello I am pretty new in electronics and want to fix my servo at a certain position like 135 degree and 315 degree but my servo keeps rotating continuously. I tried servo.write(135); but it did't work at all.

How should I make my servo on a fixed position for each command from bluetooth?
Thanks in advance.

A 360 degree or continuous rotation servo will rotate but cannot be sent to a specific position. A standard servo can be positioned to e.g. 135 degrees but it will never rotate continuously. There are very few servos that can do 315 degrees, most are limited to about 180.

The MG996R (which is what I guess you mean) is available in both versions. You probably need a different servo. What EXACTLY are you trying to do?


Sir, I want to send a letter to the bluetooth and want to set parameter for the letter to the servo to keep on 135 degree or 15 degree. And want another same thing to get in 195 or 315 degree.

MG996R servo cannot move to positions greater than approximately 180 degrees. So 195 and 315 are impossible.


OK let’s forget about 180+

I configured my mechanism and I need to do this. But this doesn’t happen at all.

#include <Servo.h>
char state = 0;
Servo name_servo;

int servo_position = 0;

void setup() {

name_servo.attach (3);
int state = 0;
name_servo.write (180);
void loop() {

if(Serial.available() > 0){
state =;}

if(state == ‘w’){

name_servo.write (0);
else if(state == ‘s’){

name_servo.write (45);
else if(state == ‘a’){

name_servo.write (60);
else if(state == ‘d’){

name_servo.write (180);


You have 2 versions of 'state', one global char and one int local to setup(). Make your mind up.

Put a Serial.print or two in loop() to see if you're getting the values in state that you're expecting. And describe exactly what the code is doing. Is it still rotating continually? If the servo doesn't even move to the initial write(180) then you have a power or wiring problem.

How is your servo connected and powered? A circuit diagram would help.


Servo ,
VCC - 5V arduino
GND - GND arduino
3rd pin - pwm 3 arduino


tx - rx arduino
rx - tx arduino
5v - 5v arduino
gnd - gnd arduino

Sir, I want to send w and want the servo to get in position 0 degree. It's not rotating anymore but initially as I wrote servo.write(180) it gets in 180 degree but other commands does not make it to the position I want.

Powering a servo that big from the Arduino 5V pin is a very bad idea. Use an external power supply, 4 x AA batteries would do, preferably NiMH rechargeables.

And if that doesn't do it, as I said before, put some Serial.prints in to see if you are actually getting values you expect.


Some simple code for testing servos.

// zoomkat 7-30-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {

void loop() {

  while (Serial.available()) {

    if (Serial.available() >0) {
      char c =;  //gets one byte from serial buffer
      readString += c; //makes the string readString

  if (readString.length() >0) {
    int n = readString.toInt();