• Best bet is probably to look at some of Chrome's own examples... They have one on turning a LED on and off on an Arduino:

    https://github.com/GoogleChrome/chrome-a­pp-samples/tree/master/serial/ledtoggle

    and reference on the serial API here:

    http://developer.chrome.com/apps/serial.­html

    Note that the examples are for the newer Chrome M33, not the version of Chrome that you may have by default on your chromebook (not sure).

    On an Arduino their example requires you to compile a special program on the Arduino, and they just send the characters "y" and "n" to it. On Espruino, you should be able to just modify their code (at the bottom of main.js) to send "LED1.set()\n" and "LED1.reset()\n" instead.

    From the other examples hopefully you can work out how to get character data back. In the Web IDE, we tend to just 'wrap' the data in something that's easy to pick out on the PC - for instance:

    console.log("<<"+"<<"+mydata+">>"+">>")
    

    And then when it executes it outputs <<<<mydata>>>> which is pretty easy to detect and extract with a simple bit of code.

About

Avatar for Gordon @Gordon started