PING and Servo issue

I have a standard servo and the PING))) sensor connected to pin 9 and 7 respectively. When running the demo code for both, they work as needed, but when I want to have the servo move and have the PING check the distance, the light on the ping blinks very dimly and the servo moves poorly.

I am running of USB power.

#include <Servo.h> 

Servo myservo;

const int pingPin = 7;
int val=0;
void setup() {
  // initialize serial communication:
   myservo.attach(9);
  Serial.begin(9600);
}

void loop()
{
  // establish variables for duration of the ping, 
  // and the distance result in inches and centimeters:
val=val+1;
if (val==180)
{
  val=0;
}
  
  long duration, inches, cm;

  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);

  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);

  Serial.print(duration);
  Serial.print( val);
  Serial.println();
  delay(10);
  servo();



}
void servo()
{
   myservo.write(val);
   delay(15);
}

I don't see anything wrong with your code. Is it possible you've got it wired up wrong? The 3v and 5v pins are right next to each other...

Nope, the 5volt is connected to 5V on the board.

What I noticed is it kinda stutters
it would be like !....!.........!...!......!....

I always power (relatively) high-power stuff like servos off a separate supply (don't forget to common the grounds!)