I am trying to write an if else statement that activates a continuous servo motor for x amount of time, then stops and is only activated again once the else part of the statement is triggered. Is this possible? I tried doing it with a delay but it just looped back through the if statement once the delay ended, which I don't want. I also tried to use a 180 servo but I need it to do 3 full rotations, which that servo isn't capable of.
First, you need to post the program you have tried so we can see it.
Second, have you considered a sail-winch servo which can do 3 turns (some of them more) with position control.
Third, the demo Several Things at a Time illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.
I tried doing it with a delay but it just looped back through the if statement once the delay ended,
That has nothing to do with the sort of delay you used but the way you have written your code that surrounds the delay, when you post your code we can see what.
sabbicat:
Here was my attempt, mostly at this point I'm just confusing myself.
if (currentMillis - previousMillis2 >= interval) {
previousMillis2 = currentMillis;
if (previousMillis2 < 2000) {
For both variables called previousMillisX, your setting them to current millis and then expecting them to be less than 2000 to trigger your if statements..
Well unless your arduino has been on for less than 2 seconds, or has been on for something like 50 days till it flips back to zero, your currentmillis is going to be greater than 2000 so it doesn’t do anything.