public void SetPWM(ArduinoMegaPWMPins pin, int newValue) { if (firmata.IsInitialized == false) { return; } var currentPin = firmata.Pins[(int)pin]; // TODO : Decide on whether this should throw an exception if (!currentPin.IsPWMMode()) { return; } // Send the message to the board firmata.SendMessage(new AnalogMessage() { Pin = (byte)pin, Value = newValue }); // Update the firmata pins list currentPin.CurrentValue = newValue; }
public void SetPWM(ArduinoMegaPWMPins pin, int newValue) { if (firmata.IsInitialized == false) return; // TODO : Decide on whether this should throw an exception if (firmata.Pins[(int)pin].CurrentMode != PinModes.PWM) return; // Send the message to the board firmata.SendMessage(new AnalogMessage(){Pin = (byte)pin, Value = newValue}); // Update the firmata pins list firmata.Pins[(int) pin].CurrentValue = newValue; }