Reply To: Multi User – PIN CHANGE Event

About Forums Forum Multi User – PIN CHANGE Event Reply To: Multi User – PIN CHANGE Event

#765

I have looked into this further (now that I’m back home and have access to an Arduino). Reading the PWM value is not possible on the Arduino. You can only set the value using analogWrite (http://arduino.cc/en/Reference/analogWrite), but you cannot read it. The reason you are seeing the value update when listening for the CHANGE event on the led pin is because the Pin object is storing the value that was set. This value is not coming from the Arduino, which is why you are not seeing the slider move in the other client application. It has no way to know that the PWM value changed.

I understand what you are trying to do, but there is really no easy way to accomplish it and this isn’t a Breakout or Firmata issue. You’d have trouble doing this in c on an Arduino as well (and it would actually take 2 Arduino boards connected via serial just to simulate this outside of Breakout).

StandardFirmata does make reading output pin data possible because all write values are stored in an array. So you are not getting the value from the pin itself, but rather from the stored value that was written to the pin. As I mentioned, there is a private method queryPinState in IOBoard.js that can get the stored PWM pin value from the Arduino. I could make this method public and you could use it to get the PWM value but you would have to use setInterval to poll for the value which is not ideal.

The better solution to what you’re trying to accomplish is to open up a websocket connection between your 2 client applications, and send the PWM value from the client that is driving the PWM pin to the other client that is visualizing the pwm value.