Servo timer

Without the 1 millisecond delays (I think they are 1 millisecond) it would not work.

Unless val is 0, the 5 calls to delay(1) are not contributing much. If val is 0, I would expect that to mean no delay, so the 5 calls to delay(1) are creating a delay when none is wanted.