Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Rise of the Nodebots

145 views

Published on

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.

Published in: Internet
  • Be the first to comment

  • Be the first to like this

Rise of the Nodebots

  1. 1. RISE OF THE NODEBOTS Presented by Joel Lord Midwest JS August 18th 2017
  2. 2. @joel__lord #midwestjs ABOOT ME, EH? Javascript Junkie Technology enthusiast Tinkerer 8/18/17 2
  3. 3. @joel__lord #midwestjs AGENDA Demo Hardware Software Setting up the Arduino board Setting up the project Building a Hello World! Building the Night light 8/18/17 3
  4. 4. @joel__lord #midwestjs I LIKE ROBOTS 8/18/17 4
  5. 5. @joel__lord #midwestjs I LIKE ROBOTS 8/18/17 5 Travel Tip !
  6. 6. @joel__lord #midwestjs I LIKE ROBOTS 8/18/17 6
  7. 7. @joel__lord #midwestjs OUR FINAL PRODUCT 8/18/17 7
  8. 8. @joel__lord #midwestjs YOUR KIT 1 Arduino board 1 USB Cable 1 Breadboard 4 Jumper Cables 2 Red LEDs 2 220 ohms Resistors 1 Photoresistor 1 1k ohms Resistor 8/18/17 8
  9. 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
  10. 10. HARDWARE 8/18/17 10
  11. 11. @joel__lord #midwestjs HARDWARE - BREADBOARDS 8/18/17 11
  12. 12. @joel__lord #midwestjs HARDWARE - RESISTORS 8/18/17 12 𝑅 = 𝑉 𝐼 𝑅 = 5𝑣 0.02𝐴 𝑅 = 250 𝑣 𝐴 𝑅 = 250Ξ©
  13. 13. SOFTWARE 8/18/17 13
  14. 14. @joel__lord #midwestjs SOFTWARE - NODE JavaScript runtime built on Chrome's V8 JavaScript engine. Open Source and available freely Available at https://nodejs.org/ 8/18/17 14
  15. 15. @joel__lord #midwestjs SOFTWARE - NPM Node Package Manager Comes out of the box with NodeJs Available at https://www.npmjs.com/ 8/18/17 15
  16. 16. @joel__lord #midwestjs SOFTWARE – JOHNNY FIVE Available through npm Documentation at http://johnny- five.io/ 8/18/17 16
  17. 17. PROJECT SETUP 8/18/17 17
  18. 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
  19. 19. @joel__lord #midwestjs SETUP YOUR PROJECT Create a new project using Β­ npm init Install Johnny-Five using Β­ npm install --save johnny-five 8/18/17 19
  20. 20. @joel__lord #midwestjs SETUP YOUR PROJECT – NPM INIT > npm init name: (test) version: (1.0.0) description: entry point: (index.js) test command: git repository: keywords: author: license: (ISC) About to write to /Users/jlord/Documents/Projects/test/package.json: { "name": "test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1" }, "author": "", "license": "ISC" } Is this ok? (yes) 8/18/17 20
  21. 21. @joel__lord #midwestjs SETUP YOUR PROJECT – INSTALL JOHNNY-FIVE 8/18/17 21 > npm install --save johnny-five npm WARN package.json test@1.0.0 No description npm WARN package.json test@1.0.0 No repository field. npm WARN package.json test@1.0.0 No README data > serialport@4.0.7 install /Users/jlord/Documents/Projects/test/node_modules/johnny-five/node_modules/serialport > node-pre-gyp install --fallback-to-build [serialport] Success: "/Users/jlord/Documents/Projects/test/node_modules/johnny- five/node_modules/serialport/build/Release/serialport.node" is installed via remote johnny-five@0.10.6 node_modules/johnny-five β”œβ”€β”€ lodash.debounce@4.0.8 β”œβ”€β”€ lodash.clonedeep@4.5.0 β”œβ”€β”€ ease-component@1.0.0 β”œβ”€β”€ color-convert@1.2.2 β”œβ”€β”€ browser-serialport@2.1.0 β”œβ”€β”€ temporal@0.5.0 β”œβ”€β”€ nanotimer@0.3.10 β”œβ”€β”€ firmata@0.15.0 β”œβ”€β”€ chalk@1.1.3 (escape-string-regexp@1.0.5, ansi-styles@2.2.1, supports-color@2.0.0, has-ansi@2.0.0, strip-ansi@3.0.1) β”œβ”€β”€ es6-shim@0.35.2 └── serialport@4.0.7 (bindings@1.2.1, commander@2.9.0, lie@3.1.0, debug@2.6.0, nan@2.5.0, object.assign@4.0.4)
  22. 22. HELLO WORLD 8/18/17 22
  23. 23. @joel__lord #midwestjs WIRING UP A LED 8/18/17 23
  24. 24. @joel__lord #midwestjs CODING OUR LED 8/18/17 24 var j5 = require("johnny-five");
  25. 25. @joel__lord #midwestjs CODING OUR LED 8/18/17 25 var board = new j5.Board();
  26. 26. @joel__lord #midwestjs CODING OUR LED 8/18/17 26 board.on("ready", function() { });
  27. 27. @joel__lord #midwestjs CODING OUR LED 8/18/17 27 var led = new j5.Led(13);
  28. 28. @joel__lord #midwestjs CODING OUR LED 8/18/17 28 led.blink(500);
  29. 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. 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 >> Ø
  31. 31. BUILD A NIGHT LIGHT 8/18/17 31
  32. 32. @joel__lord #midwestjs WIRING 8/18/17 32
  33. 33. @joel__lord #midwestjs CODING 8/18/17 33 var j5 = require("johnny-five");
  34. 34. @joel__lord #midwestjs CODING 8/18/17 34 var board = new j5.Board();
  35. 35. @joel__lord #midwestjs CODING 8/18/17 35 board.on("ready", function() { });
  36. 36. @joel__lord #midwestjs CODING 8/18/17 36 var led = new j5.Led(13);
  37. 37. @joel__lord #midwestjs CODING 8/18/17 37 var sensor = new j5.Sensor("A0");
  38. 38. @joel__lord #midwestjs CODING 8/18/17 38 sensor.on("change", function() { });
  39. 39. @joel__lord #midwestjs CODING 8/18/17 39 if (sensor.value > 750) { led.on(); }
  40. 40. @joel__lord #midwestjs CODING 8/18/17 40 else { led.off(); }
  41. 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(); } }); });
  42. 42. @joel__lord #midwestjs CODING 8/18/17 42 Ø node index.js 1484955651472 Device(s) /dev/cu.usbmodem1421 1484955651484 Connected /dev/cu.usbmodem1421 1484955653114 Repl Initialized >> Ø
  43. 43. @joel__lord #midwestjs THE END – THANK YOU ! 8/18/17 43 Presented by Joel Lord August 18th 2017 Twitter: @joel__lord Github: joellord

Γ—