First steps with my new Espruino

June 12, 2014

Tags: #javascript #gpio #iot #espruino

Espruino Board
Today my first Espruino (ordered at Phenoptix) arrived. Espruino is pure JavaScript bare to the metal of a microcontroller.

It took me exactly 3 minutes to get the Espruino out of the packaging, connecting it to my computer, start the Chrome Web IDE, flashing with the current firmware and run my first script. And it worked! Out of the box! I'm excited! Very excited!

Ok, well, my first "script" was just
LED1.set();
and
LED1.reset();
Espruino Web IDE
Nothing spectacular. But perhaps... What is this "LED1"?
Espruino comes with several built-in constants for each GPIO pin, and also the 3 built-in LEDs and the two buttons are GPIOs which can be addressed with an own constant. Nice!

So, this led me to the following first use case: Turn the three LEDs on and off, one after another, when the button is pressed. This can be achieved by using the setWatch() function, which is able to monitor the GPIOs and running a function when the GPIO is invoked:
setWatch(function () {
LED1.set();
setTimeout("LED1.reset(); LED2.set();", 500);
setTimeout("LED2.reset(); LED3.set();", 1000);
setTimeout("LED3.reset()", 1500);
}, BTN, {
repeat : true,
edge : "rising"
});
Again, it worked just from the start. Here's a little demo video which I took just to show the above mentioned script/usecase:
Life can be so easy! :-)

« Project Avatar at JavaOne 2014 Avatar.js & Project Avatar - Feedback from conference talks »