I have the error: expected unqualified-id before 'if'
The error is occurring because you have 2 if statements outside of a function. You could move them into the ping() function which would fix the error but there seems to be a logic error with the 2 if statements as well.

If distanceCm is 20, both if statements execute one right after another, so I doubt you'll see the LED turn on. Perhaps an if/else might work.

if(distanceCm &lt; 21){
  digitalWrite(13, HIGH);
}
else{
  digitalWrite(13, LOW);
}