Slide 1

Slide 1 text

Where does the javascript run, anyway? A beginner’s guide to js + hardware C J Silverio @ceejbot

Slide 2

Slide 2 text

Tab Hunter easily located?

Slide 3

Slide 3 text

I never tracked the cat.

Slide 4

Slide 4 text

Then I went to a hack day.

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

That’s a cat about to be tracked.

Slide 7

Slide 7 text

Text Let’s talk microcontrollers. Arduino, Raspberry Pi, Beaglebone, and beyond.

Slide 8

Slide 8 text

Hardware input & output What the Arduino & the Pi have in common: inputs and outputs.

Slide 9

Slide 9 text

Connect to the physical world. Turn lights on & off. Run motors. Fire missiles at nodecopters. !

Slide 10

Slide 10 text

General-purpose I/O aka the GPIO or the “pin”

Slide 11

Slide 11 text

The super power of a microcontroller is the GPIO. The GPIO connects variables in software to physical objects: the power level on a wire is information.

Slide 12

Slide 12 text

Breadboard 101 The + and – columns are connected. The rows are connected. Board +/5V ➜ + Board ground ➜ –

Slide 13

Slide 13 text

Lighting an LED is simple. Power to breadboard resistor from + to long wire on the LED LED short wire to breadboard – – to board GND

Slide 14

Slide 14 text

Software! Decision-making! Now we make the microcontroller do some work.

Slide 15

Slide 15 text

Text Arduino Easy to start with! Lots of GPIO pins.

Slide 16

Slide 16 text

Text Button: a typical circuit power, ground, control signal software on the Arduino to read its state

Slide 17

Slide 17 text

We’re about to get the javascript into it.

Slide 18

Slide 18 text

Johnny-Five to the rescue StandardFirmata sketch ➜ Arduino npm install johnny- five write javascript

Slide 19

Slide 19 text

Async Goodness with Buttons ! var five = require('johnny-five'); var board = new five.Board(); ! board.on('ready', function() { // signal goes into arduino pin 8 var button = new five.Button(8); ! button.on('down', function() { console.log('down'); }); button.on('up', function() { console.log('up'); }); button.on('hold', function() { console.log('holding'); }); });

Slide 20

Slide 20 text

Tethered. :( You need to stay connected to a host capable of running Node.js, which the Arduino is not.

Slide 21

Slide 21 text

Upgrade the microcontroller! Let’s move from the early 80s to the late 90s.

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

You run Linux on these. OMG.

Slide 24

Slide 24 text

Decisions, decisions. Arduino tiny Arduinos Raspberry Pi Beagle cheap cheaper CPU! more CPU! 14 pins size varies 8 pins 65 pins lots of modules features vary great video more memory C++ js tethered C++ any language any language prototyping mobile projects general use, audio-vis CPU-intensive lots of connections

Slide 25

Slide 25 text

Text Cat Tracker uses 2 boards Teensy on the cat, Beaglebone at the cat door

Slide 26

Slide 26 text

Next gen Tessel Espruino Javascript as first-class language

Slide 27

Slide 27 text

Next steps! Go to a hack day! http://nodebots.io Run a hack day!

Slide 28

Slide 28 text

http://node-ardx.org The Arduino experimenter’s guide for Javascript

Slide 29

Slide 29 text

Practical Electronics for Inventors Paul Scherz & Simon Monk

Slide 30

Slide 30 text

Play! Putter around. Buy two of everything because you will melt things sometimes. It’ll be okay.

Slide 31

Slide 31 text

Learn strange new things. USB? Bluetooth? Serial? Radios? Reverse-engineer something!

Slide 32

Slide 32 text

Go forth & build!