Troubles what did not go well in controlling servo by Arduino


I will blog a different topic than the laser because I wrote about laser a lot.

I will write down the topic because I had troubles of controlling servo by Arduino, though I used to handling LEDs by Arduino.

To smooth servo movement more detail – basic

If you control servo, normally you will write arduino program below:

#include <Servo.h>
Servo servo;

void setup(){
    servo.attach([pin number for controlling servo]);
    angle = 120; // 0-180 degree
void loop(){}

Normally it is good you can write code easily because of using degree, but if you want to control more smoothly and detail, you can control by


However, it becomes little difficult how to specify angle; thus unit is different from write() and writeMicroseconds().

In reference, writeMicroseconds takes argument from 1000 to 2000 normally, but some servos take from 700 to 2,300.You need to test the range.
In fact, the servo I used takes the range more wider.

Arduino reference(Servo#writeMicroseconds() ):

Therefore, writeMicroseconds() has a merit that moves servo smooth though this function takes time and complex.

Unable to move continuously

Although I cannot search deeply, servo cannot move without using delay() when I move servo continuously in loop().I think there is a time lag that run this code and arriving at the position though I don’t know the reason completely.
This is related to servo types and other implementation, but I need delay(15);.

jittering – controlling from external

I wrote a code that continuosly receive and parse values from serial, and control servo by using that values.
I think it goes well, but servo happened to move jittering when connecting serial device and move smooth when disconnecting serial device.It may be overloaded.

The reason why I use “SoftwareSerial” code. Actually, I should use “Hardware” Serial(using tx, rx pins), but I used SoftwareSerial because I want to debug by retrieving values via USB, in PC.
However, SoftwareSerial is heavier than “hardware” Serial, and I found the article not to use standard SoftwareSerial.

In this article, there are alternative recommendations below:

In my situation, I cannot improve the problem when using these alternatives..
So I improved by using hardware Serial.

Although, I think this depends on Arduino’s specs(I use this Arduino Pro mini 5v).So the problem will appear when I use more servo.

And, I used 6 servos in my situation and I have other problems I got values via wireless,,,I will write down this other time.