Skip to content Skip to sidebar Skip to footer

Tutorial MG995 Servo Arduino Code Continuous Rotation

 MG995 Servo Arduino Code 

Tutorial MG995 Servo Motor Arduino Code Continuous Rotation  -  This time we will learn about the MG995 Servo Motor. The MG995 servo is a servo motor that can move continuously without any degree of rotation limitation.

If you have ever used a servo motor such as the Tower Pro SG90 and MG996R, that servo motor is  standard servo type and can be controlled using a specified degree angle.

Arduino MG995 Servo Tutorial

In the Example program code that can be found on the Arduino IDE for Servo Control, we can easily move the servo motor with the command "myservo.write (degrees);", then the servo will move to that degree.

The MG995 servo is different in how it operates. I tried programming Arduino several times to control the servo motor from this tower pro using the default program available on the Arduino IDE, but it didn't work. 

Tutorial MG995 Servo Arduino Code Continuous Rotation TowerPro
MG995 Servo Arduino

So, after I studied and looked for how to control this Continuous servo, I found a way to drive this servo motor.

Because MG995 Tower Pro 360 is a servo type with continuous rotation, there are 3 conditions that must be specified is Stop position, Turn left and Turn right. Of the three positions, the basic command is to use the "writeMicroseconds" command.

 Based on several experiments that I did, the microsecond value for when these conditions are:

  • Stop position - writeMicroseconds(1500)
  • Turn left  - writeMicroseconds(1000)
  • Turn right - writeMicroseconds (2000)


To be able to practice the values ​​above, please connect the servo to your Arduino. Use it on one of the PWM pins. The PWM pins are 3, 5, 6, 9, 10, and 11. If you don't know how to assemble them, you can see the circuit here.

Servo Code MG995 Arduino

After that, I wrote the basic program code. Please upload a copy of the program line below, then paste it into the Arduino IDE. Then upload it to Arduino Uno.

#include <Servo.h>
Servo servo;
void setup() { 

void loop() { 
// rotate counter-clockwise full-speed

// rotation stopped

// rotate clockwise full-speed

// rotation stopped

You can see the results.

If in a certain position it doesn't work, for example you can't turn to the left smoothly, you can try to change the value of the microseconds to a little more or less than the value of 1000. 

By my experiment, each servo sometimes has a slightly different command than other servo. From that, please calibrate a suitable value of microSeconds for your servo. 

I hope this article is useful. If you find this article useful for others, please share this article so that other friends understand how the 360 degree continuous servo MG995 from Tower Pro works. 


Post a Comment for "Tutorial MG995 Servo Arduino Code Continuous Rotation"