Slide 1

Slide 1 text

arduinode.js making arduino and node.js talk

Slide 2

Slide 2 text

nategood.emit( "greeting", "ohai, i'm nate good" );

Slide 3

Slide 3 text

director of software engineering at ShowClix

Slide 4

Slide 4 text

i am not an electrical engineer n00b

Slide 5

Slide 5 text

fascinated with human- computer interaction

Slide 6

Slide 6 text

fascinated with human- computer interaction making things talk

Slide 7

Slide 7 text

meet arduino ciao! sono italiano!

Slide 8

Slide 8 text

a microcontroller for /(programmers)|(artists)|(the rest of us)/

Slide 9

Slide 9 text

small computer single integrated circuit: processor, memory, io

Slide 10

Slide 10 text

single board arduino uno, arduino mega, lilypad, parallax, dwengo many flavors

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

atmega 328

Slide 13

Slide 13 text

usb (serial port) power

Slide 14

Slide 14 text

pins

Slide 15

Slide 15 text

3.3V + 5V power ground pins

Slide 16

Slide 16 text

digital io pins input push switch ir receiver output leds servos (pwm)

Slide 17

Slide 17 text

analog input pins* input potentiometer joystick photoresistors * pins can also be used as digital io

Slide 18

Slide 18 text

programming your arduino it's alive!

Slide 19

Slide 19 text

32Kb worth to store embedded programs flash memory

Slide 20

Slide 20 text

simple C like language for microcontrollers wiring language

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

write, compile, monitor, & upload programs arduino ide

Slide 23

Slide 23 text

standalone arduino program stop... demo time

Slide 24

Slide 24 text

talking to your arduino from a host computer arduino talk

Slide 25

Slide 25 text

arduino acts as any other serial device serial

Slide 26

Slide 26 text

Locate your arduino > ls /dev ... tty.usbserial-A6008jCB ... Use screen to monitor input Arduino IDE also has built in serial monitor > screen /dev/tty.usbserial-A6008jCB 9600

Slide 27

Slide 27 text

wiring provides a serial library for arduino serial on arduino

Slide 28

Slide 28 text

void setup(){ // Open connection Serial.begin(9600); } void loop(){ // Send single byte with value 45 Serial.write(45); // Send multiple bytes (ASCII) int bytesSent = Serial.write("hello"); }

Slide 29

Slide 29 text

but serialsly, we can do better.

Slide 30

Slide 30 text

protocol for speaking serial to arduino abstracts the ugly of serial communication removes the need for writing wiring (aka arduino code) altogether set and forget upload a single standard firmata protocol program to arduino firmata

Slide 31

Slide 31 text

step 1 upload a standard firmata sketch to your arduino (available in IDE) step 2 use a firmata client library to talk to the arduino using this standard protocol step 3 plug in your arduino and start making it talk how's it work?

Slide 32

Slide 32 text

speak firmata in realtime with your arduino firmata client app

Slide 33

Slide 33 text

windows, mac, and linux clients os independent

Slide 34

Slide 34 text

awesome for prototyping w/ new io elements prototyping :-)

Slide 35

Slide 35 text

firmata in action stop... demo time

Slide 36

Slide 36 text

firmata libs for most languages, including js firmata libs http://firmata.org/wiki/Download

Slide 37

Slide 37 text

npm install firmata node.js + firmata

Slide 38

Slide 38 text

var Board = require('firmata').Board, tty = "/dev/tty.usbserial-A6008jCB"; var board = new Board(tty, function() { var analogPin = 3, ledPin = 13, on = false; board.pinMode(analogPin, board.MODES.ANALOG); var readAndSleep = function() { board.analogRead(analogPin, function(sleep) { var mode = on ? board.HIGH : board.LOW; board.digitalWrite(ledPin, mode); on = !on; setTimeout(readAndSleep, sleep); }); }; readAndSleep(); });

Slide 39

Slide 39 text

javascript + node.js event driven event driven makes it awesome for the web where we're waiting around for user input real world also pretty event driven a lot of waiting around for io to happen why node?

Slide 40

Slide 40 text

node + firmata + arduino = real time rating stop... demo time

Slide 41

Slide 41 text

express web app publishes to redis redis in turn notifies subscribers of the rating node.js (subscribed to redis) receives event, calculates rotation, and speaks firmata arduino receives firmata protocol, moves servo accordingly rate nate demo

Slide 42

Slide 42 text

what next? real time node redis pubsub, socket.io components rfid, infrared, lcds, variable resistors, accelerometers, break-out boards beyond arduino x10, raspberry pi where? sparkfun, radioshack, digikey, make

Slide 43

Slide 43 text

thanks nate good director of software engineering showclix github nategood twitter @nategood blog blog.nategood.com email me@nategood.com