Constrain() ultrasonic inputs to control LED

This is the original code without the added two lines and it works perfectly. The values are read and displayed in the serial monitor. I wanted to limit those values. I don't know how they read them without using digitalRead() or analogRead()

Code:
// Arduino pin numbers for the sensor output and input pins
const int pingTrig = A0;
int pingEcho = A1;

void setup() {
// initialize serial communication
Serial.begin(9600);
// initialize sensor pins
pinMode(pingTrig, OUTPUT); // change A0 pin mode to digital output
pinMode(pingEcho, INPUT); // change A1 pin mode to digital input
}

void loop()
{
// establish variables for duration of the ping,
// and the distance result in inches and centimeters:
long duration, inches, cm;

// The HC-SR04 is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse
digitalWrite(pingTrig, LOW);
delayMicroseconds( 5);
digitalWrite(pingTrig, HIGH);
delayMicroseconds(10);
digitalWrite(pingTrig, LOW);

// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);

Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();

delay(100);
}

long microsecondsToInches(long microseconds)
{
// According to the Ping sensor datasheet, there are
// 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
// second). This gives the distance travelled by the ping, outbound
// and return, so we divide by 2 to get the distance of the obstacle.

return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.

return microseconds / 29 / 2;
}

output:
5 in, 12 cm
1 in, 4 cm
3 in, 8 cm

output is based on distance to the sensor