Balancing robot - Tuning

Unintentional oscillation is due to improper tuning or inadequate electromechanical design. Kp may be much too high, or the motor/motor power behavior is too nonlinear for PID to compensate.

What are the magic numbers 5, 30 and 1 doing in the motor analogWrite() call? Where do you check for excessive values for PWM?