Better PWM write function

analogWrite disrupts the output wave when called