modify analogWrite() and digitalWrite() to check pin mode.
add some comments