Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nodebots NYCJavascript Workshops

Nodebots NYCJavascript Workshops

Documentation for workshop done for NYC Javascript:
http://www.meetup.com/NY-JavaScript/events/227872713/

Stefania Druga

February 03, 2016
Tweet

More Decks by Stefania Druga

Other Decks in How-to & DIY

Transcript

  1. Plan • Learn what Arduino/Johnny Five is and complete setup(15’)

    • Form groups and follow workshop steps(60’) • Demo (15’)
  2. Before we start • No silly questions • If it

    doesn’t work it’s probably the hardware :) • We’re here to experiment and learn from each other • Code of conduct: be excellent with each other
  3. Microcontroller A microcontroller is a small computer on a single

    integrated circuit containing a processor core, memory, and programmable input/output peripherals.
  4. C vs Javascript void loop() { int val = analogRead(A0);

    Serial.println(val); delay(500); } board.on("ready", function() { var s = new j5.Sensor(‘A0’) setInterval(function() { console.log(s.value); }, 500); }); Typical Arduino Sketch Using johnny-five
  5. Johnny-Five API • 36 component classes: Board, Led, Piezo, Button,

    Pin, Accelerometer, Servo, Button…. • Each component class comes with their own events and methods. Led class has methods: blink(), on(), off(), toggle(), strobe(), fade()… Button class has events: “hold”, “down”/“press”, “up”/ “release”
  6. Handling Board Events • Just like JQuery var five =

    require("johnny-five"); var board = new five.Board(); board.on("ready", function() { var led = new five.Led(13); led.blink(500); }); • Other events likes: “connect”, “warn”, “fail”, “message”
  7. Setup • 1. Install Node • 2. Install NPM library

    Johnny-Five • Here are detailed instructions for setup
  8. Prototype time • Let’s make teams • 1st step: Choose

    an input of your choice—we are using a web button—and hook it up to an LED output on your Arduino! • 2nd step: Use or design a sensor of your choice to gather some data and send to your browser to display. • 3rd step: Modify your script from second step to integrate sockets so you can use your sensor to trigger events on multiple machines, and update live! • Demo time (20’)
  9. Step 1: Web Button A bit more complex :) follow

    instructions here: https://goo.gl/3HcwwP
  10. Now it’s your turn! • Use the tools that we’ve

    learned to build a cool app that utilizes the Arduino! • Remember, we can • Trigger events from sensors on the Arduino or from buttons on our webpage • Send data gathered by our Arduino to show or trigger events on our app’s webpage • Use sockets to live update on multiple screens