make servo move slowly

ok so i just finished making plans for a robotic arm.
what is need to know is how can i write the code so
if the pot goes from 0 to 1023. instead of the servo quickly jumping to the position, i want it move slowly (about 180º in 5 seconds)

i hope you could understand that
:slight_smile:

Yes. Set a goal and chase it.

int targetValue = 1023;
int thisValue = 0;

void loop()
{
   // get potentiometer value into targetValue here

   if(thisValue < targetValue)
      thisValue ++;

   if(thisValue > targetValue)
      thisValue--;

   // set servo output here with thisValue

   delay(1);
}

Set delay() value to adjust the speed it changes.

whats another way to do this if you didnt want to use a delay? ie, you wanted to keep your code going fast because you got so much other stuff for it to keep doing. (i need to use an interupt which is measuring the speed of a spinning shaft calculation its RPM)

You can use blink without delay as a model of eliminating delays

There's also a servo lib variant that lets you set the speed.