Problem upload this program

Hello,
I'm a newbe. I'm trying with very simple programs. When I try to upload this file my arduino freeze and I have to reset a lot of times before upload again a new program. It's only a test program that uses both a led and a servo.
If I remove the servo code lines it works perfectly.
The code is like this:

#include <Servo.h> 
Servo myservo;
int ledPin = 13;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  myservo.attach(9);
}

void loop() {
  while (Serial.available() == 0);
  
  int val = Serial.read() - '0';

  if (val == 1) {
    Serial.println("Led is On");
    digitalWrite(ledPin, HIGH);
  } else if (val == 0) {
    Serial.println("Led is Off");
    digitalWrite(ledPin, LOW);
  } else {
    Serial.println("Move servo");
    myservo.write(30); 
  }
}

what's wrong with that code?

Thank you.
Stefano.

The code looks correct to me. I can't think of a good reason why that particular code would prevent new sketches from loading. Perhaps the auto-reset of your Arduino is not working properly. What model Arduino is it?

I have the arduino uno and I bought it 1 week ago!

I've read lots of mentions of some UNOs needing to have the firmware on the USB chip re-flashed because of USB problems. Do a search for "DFU" to find out how to do that.