long duration, inches, cm;
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
inches and cm are valued based on an uninitialized local variable. How is that helpful?
How does having a local variable with the same name as a global variable help?
int pingScan() //sets the ping for static ping servo directions
{
pingServo.write(90);
delay(delayTime);
pingServo.write(180);
delay(delayTime);
pingServo.write(0);
delay(delayTime);
pingServo.write(90);
delay(delayTime);
Prior to calling this function, you point the pingServo in the desired direction. Then, in this function, you wave it all over the place. How does that help?
delay(100);
As if all the serial printing wasn't slow enough...
You need a ping() function. You may, or may not, need a pingScan() function. The ping() function should be called from pingScan(), if you need pingScan() at all. In most other places, calling ping() is more appropriate than calling pingScan().