Code stops after some time using delay

what happens if range has the value of 4?

what kind of sensor is connected to A0.

may be good to specify the default case in the switch.

can't rule out a problem (memory leak) in the Servo code, although unlikely

i agree with Paul's suggestion except if there is a serious problem, the Serial I/F may die as well. I've used LEDs to indicate the code is find the last thing the code did