JaxNode April 2016
module.exports = leftpad;
function leftpad (str, len, ch) {
str = String(str);
var i = -1;
if (!ch && ch !== 0) ch = ' ';
len = len - str.length;
while (++i < len) {
str = ch + str;
}
return str;
}
JavaScript on Micro-controllers?
Easier to tweak the software than hardware
Arduino has horrible IDE, no debugging
Easy to make event based
Run single-threaded
Can use low power, low RAM
Espruino Pico
22 GPIO pins : 9 Analogs inputs
ARM Cortex M4, 384kb flash, 96kb
3.3v 250mA voltage regulator, accepts voltages from 3.5v to 16v
JavaScript Interpreter ES5 Compat
$25
WiFi
10/100 Mb Ethernet
2 plug and play module ports
2 USB ports
580 MHz Mediatek MT7620n
64MB RAM
32MB Flash memory
$45
Run Node.js!
Raspberry PI 3
1200 Mhz 4 core ARM CPU
4 USB ports
Ethernet
On board WiFi and BLE
40 GPIO pins
HDMI
2.5 AMP power
Run Windows and Linux
$35
ESP8266
Cheap WiFi micro-controller
Want to use newer Esp-12
Flash with Espruino
$2
Interpreted JavaScript
96Kb RAM
Espruino IDE
Light weight modules
Requires bread board or Soldering
WiFi optional
Runs full version of Node
64 MB RAM
IDE of your choice
Can use NPM
USB and PnP modules
Builtin Ethernet
Builtin WiFi
// 1
var five = require("johnny-five");
// 2
var Tessel = require("tessel-io");
// 3
var board = new five.Board({
// 4
io: new Tessel()
});
// 5
board.on("ready", function() {
// 6
var led = new five.Led("a0");
// 7
led.blink(500);
});