# Need help on programming a modified 360 degree servo

Good day guys! I am not a programmer and I'm just a beginner at using an Arduino Uno microcontroller and I badly need your help.
I just need a code/program to control the speed of the servo. My servo originally rotates 180 degrees and I modified it so it would turn 360 degrees. I just need to make it slower or faster. Hope you can help me! Thank you very much!

Hello and welcome,

There is no source code for controlling the speed of servo, you just have to make greater or smaller steps (smaller steps will make the servo slower).

How do I make that "slower steps". Thank you very much for your time!

The speed and direction of continuous rotation servos (actually, in my opinion they should not be called servos) is controlled by the parameter used in the servo.writeMicroseconds() or servo.Write() methods.

See Servo - Arduino Reference for a very simple example. Change the value used by editing it or using a variable controlled by a sensor or your program and the speed will change.

guix:
Hello and welcome,

There is no source code for controlling the speed of servo, you just have to make greater or smaller steps (smaller steps will make the servo slower).

The OP is using a continuous rotation servo so the speed can be controlled. See my previous reply.
NOTE - the method may not work with a digital servo but it will with an analogue one.

Here is an example, not really useful because it will block your code (because of delay function)

``````for (uint16_t angle = 0; angle < 360; angle ++)
{
Servo.write(angle);
delay(10);
}
``````

You can change the steps ( change “angle ++” to “angle += 5” or whatever), or just adjust the delay (in milliseconds)

For a better, non blocking code, look the Blink Without Delay example in the Arduino IDE

UKHeliBob:
The OP is using a continuous rotation servo

How do you know? He just said he modified it to rotate 360 degrees instead of 180.

Typically a "360 degrees servo" refers to a continuously rotating motor with a servo controller. You remove the potentiometer and replace it by a 1:1 voltage divider. That should make servo.write(90) to stop the motor, any value greater make it run one direction, less than, the other direction. the further away the value from 90 is, the faster it turns. E. g. servo.write(20) is faster than servo.write(40).

guix:
Hello and welcome,

There is no source code for controlling the speed of servo, you just have to make greater or smaller steps (smaller steps will make the servo slower).

I think it extremely unlikely that the servo is modified for anything other than continuous rotation, but even if it is the take a look at this VarSpeedServo - a modified Servo library with speed control - Motors, Mechanics, Power and CNC - Arduino Forum