Problems controlling continuous rotation servo with IR sensor

Thanks for using code tags!

It's generally better to put the complete program in a single code block rather than three separate ones since this would allow us to more easily copy and paste it into the IDE if we want to test your code.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you're using the Arduino Web Editor you will not have access to this useful tool but it's still unacceptable to post poorly formatted code. I recommend you to use the standard IDE instead.
CCing @232 on this:

232:

tplin:

    unsigned long currentMillis = millis(); // begin to get current time

while (currentMillis - lasttime < periodcontservo){
      continuousservo.writeMicroseconds(1480);
    }

You never update currentMillis in the while loop, and that's why it gets stuck there forever.