modified analogWrite to wait for end of conversion