JavaScript for the Physical World

JavaScript for the Physical World

If you know enough JavaScript to be dangerous, you (yes, you!) can interact with the physical world via sensors. lights, and motors. Not only do you not need an electrical engineering degree to start hacking with hardware, you don't even need to learn a new language! In this session, I'll go over a few microcontroller boards that play well with JavaScript, show a demo or two, and share resources on how you can get started with hardware.

F6c4a7544807fe0b8a874e83eb84b481?s=128

Pearl Chen

June 25, 2015
Tweet

Transcript

  1. Jav a S c r i p t fo r

    t h e P hy s i c a l Wo r l d P E A R L C H E N J AVA S C R I P T O P E N D AY 2 0 1 5
  2. He l l o ! My Na m e I

    s
  3. Only some of my microcontrollers…

  4. computer icon by Juan Pablo Bravo & painting icon by

    Mikael Westman (via thenounproject.com) X
  5. computer icon by Juan Pablo Bravo & modified classroom icon

    by Rafael Farias Leão (via thenounproject.com)
  6. (fly)light LED sculpture by Pearl Chen

  7. (fly)light LEDs by Pearl Chen

  8. (fly)light circuits by Pearl Chen

  9. A few websites I've done as a front end developer

  10. Two of my HTML5Rocks articles.

  11. I mostly work on IoT hackathon on boarding materials.

  12. W H Y A M I I N T E

    R E S T E D ? • sense the world around me → CONTEXT is KING • add internet: dumb things → smart things • screen-less experiences / ambient notifications • body and location awareness → wearables
  13. Haptic navigator prototype by Pearl Chen, Connie Leung, Harold Treen

  14. 2 T R U T H S Hardware
 is becoming

    more like
 software. Hardware
 is hard.
  15. Basic Stamp 1975: Microchip PIC example Arduino shield Arduino

  16. stacked shields (via wikipedia)

  17. H O W D O YO U C H O

    O S E ? • Price?
 $100+, < $100 USD, < $80, < $50, < $30, < $20, < $10 • Form factor?
 Dedicated space, tight space, wearable • Connectivity?
 Ethernet, Wi-Fi, Bluetooth, BLE, none • Programming language?
 Arduino, JavaScript, C++, Python, no programming • Run-time environment and processing speed?
 Arduino/Embedded vs. Linux • Community?
 Can you get help when you need it?
  18. 2 PAT H S F O R J AVA S

    C R I P T- C O M PAT I B L E B O A R D S Linux-based
 operating systems JavaScript-only boards
  19. Jav a S c r i p t - o

    n l y b o a r d s
  20. T E S S E L

  21. E S P R U I N O

  22. L i n u x - b a s e

    d 
 o p e r a t i n g s y s t e m s
  23. A R D U I N O Y U N

  24. R A S P B E R R Y P

    I
  25. I N T E L E D I S O

    N
  26. G e t t i n g s t a

    r t e d & o t h e r r e s o u rc e s
  27. H A C K S T E R .I O

  28. I N S T R U C TA B L

    E S
  29. S PA R K F U N

  30. A D A F R U I T

  31. G R O V E S TA R T E

    R K I T S
  32. W H E R E TO B U Y E

    L E C T R O N I C S ( I N T O R O N T O )
  33. S m a r t C l o c k

    B u i l t w i t h : No d e J S + I n t e l E d i s o n WA L K T H R O U G H
  34. • 500 MHz dual-core, dual-threaded Intel® AtomTM CPU • 32-bit

    Intel® QuarkTM microcontroller at 100 MHz • 1 GB RAM • 4 GB onboard flash memory • built-in Wi-Fi and Bluetooth 4.0 • Yocto Linux OS
  35. It ' s a p o s t a g

    e - s i z e d c o m p u t e r t h a t c a n c o n t ro l e l e c t r i c i t y. E S S E N T I A L LY…
  36. B r e a ko u t b o a

    r d s A C C E S S I N G G E N E R A L P U R P O S E I N P U T O U T P U T ( G P I O )
  37. S e t u p t h e b o

    a r d G E T T I N G S TA R T E D 1. Connect cables & power up 2. Install USB drivers (if needed) 3. Gain remote command line access of board 4. Update firmware 5. Get board online 6. Install an IDE (optional)
  38. C l o c k A C C E S

    S I N G G E N E R A L P U R P O S E I N P U T O U T P U T ( G P I O ) Google Calendar API 1 0 m i n u t e s u n t i l y o u r m e e t i n g !
  39. No d e G o o g l e C

    a l e n d a r A P I a p p D E S K T O P P R O T OT Y P E Follow the tutorial on Google Developers: 1. Enable Calendar API & download secret.json. 2. Install two Node libraries:
 Google Client Library & Google Auth Library 3. Copy their sample code & run it. 4. Get authorization token.
  40. R u n No d e a p p o

    n b o a r d M I C R O C O N T R O L L E R P O R T Follow my Instructables tutorial from Step 6: 1. Create/import Node app into Intel XDK. 2. Create a package.json
 & install dependencies directly on board. 3. Run Node app using command line. 4. Code Tweak: Update file path references. 5. Get authorization token.
  41. A d d e l e c t ro n

    i c s S O F T WA R E TO C O N T R O L H A R D WA R E Use MRAA & UPM libraries to talk to GPIO pins. • GPIO = General Purpose Input/Output • MRAA = low level library to talk to GPIO • UPM = higher level abstraction library (builds on top of MRAA) for various sensors More info: go.klab.ca/js-grove-samples
  42. A d d L C D s c r e

    e n S O F T WA R E TO C O N T R O L H A R D WA R E Add LCD UPM library: var  jsUpmI2cLcd  =  require  ('jsupm_i2clcd');
 var  lcd  =  new  jsUpmI2cLcd.Jhd1313m1(6,  0x3E,  0x62);
 lcd.setColor(255,  0,  0);
 lcd.setCursor(1,5);
 lcd.write('Hello!');   More info: https://github.com/intel-iot-devkit/upm/ blob/master/examples/javascript/rgb-lcd.js
  43. T h e r e s t i s J

    S c o d e I N T E G R AT I O N
  44. S m a r t C l o c k

    Wa t c h B u i l t w i t h : No d e J S + I n t e l E d i s o n D E M O
  45. C O D E T W E A K S

    Tweaks • update: 
 var lcd = 
 new jsUpmI2cLcd.SSD1308(0, 0x3C); • remove .
 setColor()
  46. Re m o t e c a t t o

    y B u i l t w i t h : No d e J S + E x p r e s s + I n t e l E d i s o n D E M O
  47. S c a r e y o u r c

    a t r e m o t e l y W E B S E R V E R • Express server: http://expressjs.com/starter/hello- world.html • Motor UPM library: https://github.com/intel-iot- devkit/upm/blob/master/examples/javascript/es08a.js
  48. TWITTER @PearlChen GOOGLE+ klab.ca/+ P E A R L C

    H E N T h a n k s !