I'm pretty sure that sketch needs a loop() function.
One or more calls to the ping() function probably need to be made.