STOPPING A SERVO

The code looks OK so I suspect a hardware problem. nCommon servo mistakes are:

  1. Using the Arduino's +5V pin to power the servo (the servo can cause the Arduino to reset)
  2. Using an external power supply for the servo but forgetting to connect the negative side of that supply to the Arduino Ground.