Parallax PING))) problem coding

I’m trying to use PING)) for the eye of my car robot.
if the length is more than 10 inches will go forward but less than will turn. simple! but i can’t get it to work because
or help me modified this code please please.

The serial display show :

IMPORTANT !  :
55 <---- first checkRange value is accurated
0 <--- why the sensor read as 0 when it is in while loop or if statement
55
0
55
0
....

Please help me I’m working on this for long long time and i never get it work

here is my code

int ledRed = 3;
int ledYellow = 2;
int sensePin = 1;
int LmotorPin = 9;
int RmotorPin = 10;
int smoothTime = 1;
int eyePin = 0;
int requireLight = 0  ;
int requireTurn = 430;
int requireTurn2 = 830;
int val = 0;
int valTurn = 0;
int i = 0;
int check =0;
unsigned long echo = 0;
 int ultraSoundSignal = 12; // Ultrasound signal pin
 unsigned long ultrasoundValue = 0;

 void setup()
 {
 Serial.begin(9600);
 pinMode(ultraSoundSignal,OUTPUT);
 pinMode(LmotorPin, OUTPUT);  
  pinMode(RmotorPin, OUTPUT); 
 
 
 }

 unsigned long ping(){
 pinMode(ultraSoundSignal, OUTPUT); // Switch signalpin to output
 digitalWrite(ultraSoundSignal, LOW); // Send low pulse
 delayMicroseconds(2); // Wait for 2 microseconds
 digitalWrite(ultraSoundSignal, HIGH); // Send high pulse
 delayMicroseconds(5); // Wait for 5 microseconds
 digitalWrite(ultraSoundSignal, LOW); // Holdoff
 pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input
 digitalWrite(ultraSoundSignal, HIGH); // Turn on pullup resistor
  echo = pulseIn(ultraSoundSignal, HIGH); //Listen for echo
  ultrasoundValue = (echo / 58.138) * .39; //convert to CM then to inches
 return ultrasoundValue;
 }

 void loop()
 {
   
    checkRange ();
   if (val > 10 )
{

   while (val > 10 )
   {
     
  digitalWrite(RmotorPin, HIGH);
   digitalWrite(LmotorPin, HIGH);
   Serial.println("in Run"); 
   check = check +1 ;
   Serial.println(check); 
   checkRange ();
   
   
   }
}
  else
   {
     
   analogWrite(LmotorPin, 0);   
  analogWrite(RmotorPin, 0);  
  delay (1000);
  analogWrite(RmotorPin, 255);
  delay (930);
  Serial.println("in Turn");
   }
   
   }
 
 
 
 void checkRange () {
 int x = 0;
 val = ping();
 valTurn = ping();
  Serial.println(val);
  delay(500); //delay 1/4 seconds.
 }

What do your debug prints tell you (and us) is happening?

ultrasoundValue = (echo / 58.138) * .39; //convert to CM then to inches

Cutting-out the middle-man could help here.

this is just a part of my code

This is just part of my solution.

Here is the serial display show :

IMPORTANT !  :
55 <---- first checkRange value is accurated
0 <--- why the sensor read as 0 when it is in while loop or if statement
55
0
55
0
....

ultrasoundValue = (echo / 58.138) * .39; //convert to CM then to inches

You are doing floating point maths with integer variables. This could easily cause you problems. I think you need to define at least these two variables as type "float".