Added some checks in the setPinMode method.