Reply To: Sketch

About Forums Forum Sketch Reply To: Sketch


This is possible using the pin state query. You need to request the pin state from the Arduino and you will need to do this by polling:

arduino.addEventListener(IOBoardEvent.PIN_STATE_RESPONSE, onPinStateResponse);
// check pin state every second
setInterval(function () {
}, 1000);

function onPinStateResponse(event) {
// note here that you use the state rather than the value property
console.log(“pin state = ” +;

However, the challenge is writing a Firmata sketch that will do what you want. If this is the only action you need to do for you’re application, there is an easier way. See Breakout/custom_examples/simple_json.html and the accompanying Firmata sketch in Breakout/custom_examples/sketches/SimpleFirmataJSON. Upload the sketch to your arduino, start Breakout Server and open simple_json.html in your browser. This demonstrates how to use a custom sketch to send a JSON string to the arduino and then simply handle it as you would any other JSON string. In your case you wouldn’t want to listen for the SYSTEM_RESET event and reset the counter since this would reset the counter when the browser is refreshed, but other than that this should enable you to do what you are looking to do and is much easier than trying to modify AdvancedFirmata or StandardFirmata.