Constrain() ultrasonic inputs to control LED

Your sketch is missing a critical line:
duration = pulseIn(pingEcho, HIGH, 30000);

Since you never measure the HIGH pulse duration on the 'pingEcho' pin, you have no way to calculate the distance.