user66071: Im trying to move a servo from one place to another while using the typical for loop you find in the servo's library example:
int lightON = 180;
int lightOFF = 90;

for (pos1 = lightOFF; pos1 <= lightON; pos1 += 1) {
  servo1.write(pos1);
  delay(15);
}

for (pos1 = lightON; pos1 >= lightOFF; pos1 -= 1) {
  servo1.write(pos1);
  delay(15);
}

The thing is that while this does work, I want to be able to move the servo a little quicker, but I can't use the delay() function because of some connectivity issues with another library (BLYNK).
How could I move the servo from lightOFF to lightON the quickest way possible without using the delay() function?

user60469: The best way is to use map() function.
void loop() {
  unsigned long progress = millis() - startMillis;

  int angle = map(progress, 0, MOVING_PEDIOD, lightOFF , lightON);
  servo1.write(angle);
}

The above code use the millis() function, therefore you do not need to worry about blocking other code.
Full instruction is available on How to control speed of servo motor

user61722: The quickest way possible from LightON to LightOFF is simply servo1.write(lightOFF); without loops or delays, in one go; no need to do it degree by degree. For example:
int lightON = 180;
int lightOFF = 90;

for (pos1 = lightOFF; pos1 <= lightON; pos1++) {
  servo1.write(pos1);
  delay(15);
}

servo1.write(lightOFF);

If you want it to move a few degrees every loop and do other things in the loop while it moves, you can time it with millis() instead of delay(). The code below should move the servo 5 degrees every 0.5s:
int moveTime = 500; // Move every 0.5s
unsigned long int startMillis = 0;
int position = lightOFF;
int step = 5; // Move 5 degrees

void loop() {
  if (millis() - startMillis >= moveTime) {
    servo1.write(position);
    if (position <= lightON) {
      position = position + step;
    }
    startMillis = millis();
  }
  // Do other things
}

Untested and incomplete, but you get the idea.

66071: <p>Im trying to move a servo from one place to another while using the typical <code>for</code> loop you find in the servo's library example:</p>
<pre class="lang-cpp prettyprint-override"><code>int lightON = 180;
int lightOFF = 90;

for (pos1 = lightOFF; pos1 &lt;= lightON; pos1 += 1) {
  servo1.write(pos1);
  delay(15);
}

for (pos1 = lightON; pos1 &gt;= lightOFF; pos1 -= 1) {
  servo1.write(pos1);
  delay(15);
}
</code></pre>
<p>The thing is that while this does work, I want to be able to move the servo a little quicker, but I can't use the <code>delay()</code> function because of some connectivity issues with another library (BLYNK).</p>
<p>How could I move the servo from lightOFF to lightON the quickest way possible without using the <code>delay()</code> function?</p>
 60469: <p>The best way is to use <a href="https://arduinogetstarted.com/reference/arduino-map" rel="nofollow noreferrer">map()</a> function.</p>
<pre><code>void loop() {
  unsigned long progress = millis() - startMillis;

  int angle = map(progress, 0, MOVING_PEDIOD, lightOFF , lightON);
  servo1.write(angle);
}
</code></pre>
<p>The above code use the <a href="https://arduinogetstarted.com/reference/arduino-millis" rel="nofollow noreferrer">millis()</a> function, therefore you do not need to worry about blocking other code.</p>
<p>Full instruction is available on <a href="https://arduinogetstarted.com/faq/how-to-control-speed-of-servo-motor" rel="nofollow noreferrer">How to control speed of servo motor</a></p>
 61722: <p>The quickest way possible from <code>LightON</code> to <code>LightOFF</code> is simply <code>servo1.write(lightOFF);</code> without loops or delays, in one go; no need to do it degree by degree. For example:</p>
<pre class="lang-cpp prettyprint-override"><code>int lightON = 180;
int lightOFF = 90;

for (pos1 = lightOFF; pos1 &lt;= lightON; pos1++) {
  servo1.write(pos1);
  delay(15);
}

servo1.write(lightOFF);
</code></pre>
<p>If you want it to move a few degrees every loop and do other things in the loop while it moves, you can time it with <code>millis()</code> instead of <code>delay()</code>. The code below should move the servo 5 degrees every 0.5s:</p>
<pre class="lang-cpp prettyprint-override"><code>int moveTime = 500; // Move every 0.5s
unsigned long int startMillis = 0;
int position = lightOFF;
int step = 5; // Move 5 degrees

void loop() {
  if (millis() - startMillis &gt;= moveTime) {
    servo1.write(position);
    if (position &lt;= lightON) {
      position = position + step;
    }
    startMillis = millis();
  }
  // Do other things
}
</code></pre>
<p>Untested and incomplete, but you get the idea.</p>
