servo stoppen wenn ping weniger als 100cm ist

He's trying to make a fan pan back and forth (using a servo), much like a sentry gun. But the bullets are replaced with a cold breeze of air. It seems the servo part is giving him trouble. Especially making it pan in a sensible way, while listening to the ping sensor.

Maybe it would be helpful to scan in smaller increments and give the servo a bit more time to react. I'm assuming that servo.write(0) and servo.write(180) should make it do a full scan.

From his description of the servo's "misbehaviour" it seems that servo.write() is nonblocking and returns instantly.