So you’ve finally managed to build a full stack application, all in Javascript. But what if your hardware programming could be done with Javascript too? In this introduction to Nodebots, you will learn how to use NodeJs to build a robot using an Arduino board. Well, maybe not a full robot but at least a blinking LED. You will learn how to add basic sensors and other general electronic components and you will learn how you can do it by yourself, at home, on a minimal budget. Come to this talk and you too will be able to contribute to the Robocalypse.
9. @joel__lord
#midwestjs
HARDWARE - ARDUINO
Open Source hardware and software
Uses an ATMega programmable chip
Programmable in C
We can use the serial port to send
instructions using the Standard
Firmata
(https://github.com/firmata/arduino)
8/18/17 9
18. @joel__lord
#midwestjs
SETTING UP THE ARDUINO
To enable communication with the serial port, you need the Standard Firmata
Plus installed
https://github.com/firmata/arduino
All the boards today come pre-configured
Still, here is how to install it
8/18/17 18
29. @joel__lord
#midwestjs
CODING OUR LED
8/18/17 29
var j5 = require("johnny-five");
var board = new j5.Board();
board.on("ready", function() {
var led = new j5.Led(13);
led.blink(500);
});
Issues on your Mac ? http://www.wch.cn/download/CH341SER_MAC_ZIP.html
30. @joel__lord
#midwestjs
SHOW ME SOME BLINK
8/18/17 30
Ø node hello.js
1484955651472 Device(s) /dev/cu.usbmodem1421
1484955651484 Connected /dev/cu.usbmodem1421
1484955653114 Repl Initialized
>>
Ø
41. @joel__lord
#midwestjs
CODING
8/18/17 41
var j5 = require("johnny-five");
var board = new j5.Board();
board.on("ready", function() {
var led = new j5.Led(13);
var sensor = new j5.Sensor("A0");
sensor.on("change", function() {
if (sensor.value > 750) {
led.on();
} else {
led.off();
}
});
});