Issue Using Conditional Statement In My Project

Hey! I am using an accelerometer to measure raw values. However, once the threshold value(of acceleration) is exceeded, I'd like the attached servo motor to sweep for 5 seconds then return to a normal state of measuring values. I have the code to obtain raw values already. However, how do I achieve what I want?

Have a look at the beginner's millis() tutorial.and the several things at a time tutorial to see how to use millis() for timing. When you start to sweep, save the value of millis() in a variable. Then, each time through loop(), check if the current value of millis() minus the recorded millis(). If the difference is greater than 5000 the 5 seconds have elapsed.

Always:
Use CTRL T to format your code.
Attach your current sketch between code tags.
[code]Paste your sketch here[/code]