PinMode mode = getMode(pin);
// only permit invocation on pins set to OUTPUT modes
if (!PinMode.allOutput().contains(mode)) {
throw new InvalidPinModeException(pin, "Invalid pin mode on pin [" + pin.getName() + "]; cannot setValue(" + value + ") when pin mode is [" + mode.getName() + "]");
}
// for digital analog pins, we will echo the event feedback
dispatchPinAnalogValueChangeEvent(pin, value);