How to turn servo to a specific location and then turn over
Rather than writing to 180 and 0 write to a variable.

static const int MovementAmount = 30; //degrees
int position = 90;  // 90 is the start position.
...
case 'd':
   servo.attach(12);
   position += MovementAmount;
   if (position &gt; 180)
   {
     position = 180;
   }
   servo.write(position);
   break;