by putting the statement inside the while loop like so
case 2:
while (digitalRead(leftbutton)) //while the button is being pressed
{
myservo.write(pos); //rotates servo to its current positon
delay(delaytime);
pos-=1; //position becomes one less
LastTimeButtonWasPressed = millis();
}
myservo.write(pos); //after the button stops being pressed the servo is at pos
It still does not delay.
However, I was playing around with this code and when I did this
case 2:
while (digitalRead(leftbutton)) //while the button is being pressed
{
myservo.write(pos); //rotates servo to its current positon
delay(delaytime);
pos-=1; //position becomes one less
}
myservo.write(pos); //after the button stops being pressed the servo is at pos
previousmillis = millis();
if(millis() - 5000 >= 3000UL) //if the total time - the start time is greater than 3 sec
{
//casenum = 1; //this is where the code goes wrong, it seems like it reads this if statement
//and immedietly say thinks its true
//previousmillis = currentmillis;
//interval = interval + millis();
break;
}
The code paused. But only for around 5 seconds.
There is also a time slot where it will delay and then it will just stand still after I press the button
and I am trying to get the significance of this, but I just can't figure it out