Code is not running, servo does not even spin
For starters: this bit is a strange mixture of for and while syntax:
while (int i = previous_angle) {
  i &lt;= 90; 
  i = i + 1; 
  myservo.write(i);
  delay(45); 
};  

It will compile, but probably not do what you want it to do. It should probably be:
for (int i=previous_angle; i&lt;=90; i=i+1) {
  myservo.write(i);
  delay(45); 
}

Also, previous_angle is never changed in your code after initialisation; it is always 0.
That also means that the for loop below will not do what you want (and that loop also doesn't increment i anywhere):
for (int i = previous_angle; i&gt;0;)

There may be more; make the suggested changes first and see what happens.