In several places you have:
for(previousPosition != 0; previousPosition < servocold; previousPosition += 1) // goes from 0 degrees to 180 degrees
A for loop has 3 expressions:
- the starting condition of the variable that controls the loop
- a (relational) test that determines if another iteration through the loop is needed
- usually a change in the variable that controls the loop.
Your expression 1 looks suspect, since it is a relational test, not what is usually an assignment statement. Given your comment, it probably needs to look something like:
int degrees;
for(degrees = 0; degrees < servocold; degrees++) // goes from 0 degrees to 180 degrees
This code marches through from 0 up to servocold 1 degree at a time.
Also, when you post code here, place your cursor in the IDE source code window, press Ctrl-T, which formats it for you. Then press Ctrl-A to copy all of your code. Then come to this forum, start your post, hit the pound sing (#) and copy your code between the two code tags. That makes it easier for us.