If you were using that on an Arduino as they intended, you'd have to program the Arduino first with this code, but on Espruino you can basically change this line from:
So instead of sending simple data, you can actually send JavaScript, which is then executed by the Espruino itself...
Note: you'll have to click the button 3 times before anything happens - if you want to fix that, replace:
connection.send("hello arduino");
with:
connection.send("hello espruino\n");
as because there was no new line sent before, it won't be executed, and the first button press will actually execute hello arduinodigitalWrite(LED1,1); - which won't work!
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Great! There's a nicer explanation of using Chrome Serial here: https://developer.chrome.com/apps/app_serial
And Google have an example app that includes talking to the Arduino and turning a light on and off: https://github.com/GoogleChrome/chrome-app-samples/tree/master/serial/ledtoggle#readme
If you were using that on an Arduino as they intended, you'd have to program the Arduino first with this code, but on Espruino you can basically change this line from:
to
So instead of sending simple data, you can actually send JavaScript, which is then executed by the Espruino itself...
Note: you'll have to click the button 3 times before anything happens - if you want to fix that, replace:
with:
as because there was no new line sent before, it won't be executed, and the first button press will actually execute
hello arduinodigitalWrite(LED1,1);
- which won't work!