About Forums Forum Sketch

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #844


    Gratz for all this work on the internet of things!

    My question is about programming the sketch on the arduino. Is that possible to upload a sketch (or a part of) on the arduino? or the AdvanceFirmata is the only sketch that can go on the arduino?

    I have some sketch based on OnewireThermometer and PID…

    Thx in advance.




    It is possible to create custom sketches to use with Breakout. See the readme file in Breakout/custom_examples/ and the rfid_example2.html file in the same directory.

    There is also work in progress on a one-wire firmata sketch. See the thread here on the Breakout github page:

    Also see this post on the firmata dev list: It describes how to create a sketch to communicate with Breakout.

    Keep in mind that by using a custom sketch you will not be able to use the Breakout IO objects (unless you specifically implement support for them in your sketch… which is difficult), you will only be able to send and receive sysex and string messages.



    I was going to start a new topic but I think it sort of belongs here, or is at least related to this topic.

    Is it possible to hack the AdvanceFirmata sketch?

    It might be easier to explain what I want to do – I have a potentiometer connected to the board, and when it goes above a certain value I want it to set pin 13 to HIGH. When it goes HIGH, I want to do something a webpage. I’m trying to do this by using PinEvent.Change.

    led.addEventListener(PinEvent.CHANGE, onPinChange); 


    But, as you’ve probably suspected by now, I’m getting the ‘“Warning: malformed input data… resetting buffer”’ error.

    Is it actually possible to do what I’ve just described? Or am I better off trying to find a work around?

    I think breakoutjs is fantastic btw. I found the guides very useful


    You only get Pin change events for inputs (such as buttons, potentiometers, etc). You should use an input (potentiometer) to drive an action, not an output (led). What you need to do is listen for a change event on the Potentiometer (or better yet use a triggerPoint filter – see Breakout/examples/filters/triggerpoint.html). When the threshold is crossed on the rising edge (transition of 0 -> 1 when using triggerpoint filter), set pin 13 to HIGH and do something on your website, when the threshold is crossed on the falling edge, set pin 13 to LOW. The triggerpoint filter is helpful in eliminating jitter that you can observe when using an analog input.


    Thanks for replying.

    I came across triggerPoint alright, and thanks for the heads up on Pin change events only working inputs, I wasn’t aware of this.

    I should have explained in my earlier post – the reason why I want to do this on the Arduino is because I cannot do it in the browser. I want to be able to make it do something like ‘if the value of this Potentiometer has not gone above 500 in the last 30 minutes, make the website do X’. So I want to write code something like this…

    set Arduino PIN 13 to LOW
    start 30 minute timer on Arduino
    if Potentiometer goes above 500, reset timer
    if timer reaches 30 minutes, set Arduino PIN 13 to HIGH
    if the website that is connected to Arduino sees that PIN 13 is HIGH, do X

    I can’t do this in the browser, because each time the page loads the timer will start at 0 (as I’m sure you know). (That said, I was trying to do it in the browser until a real programmer told me that it wouldn’t be possible.)

    Maybe I’m overcomplicating things; is there a simple way to check the status of the digital pins of the Arduino? So then I could then the Potentiometer code that sets the digital Pin to HIGH, and if the website sees that digitalPin 13 is HIGH, then do X?



    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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Forum’ is closed to new topics and replies.