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

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.

Pearl Chen

June 25, 2015
Tweet

More Decks by Pearl Chen

Other Decks in Technology

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. computer icon by Juan Pablo Bravo & painting icon by

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

    by Rafael Farias Leão (via thenounproject.com)
  4. 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
  5. 2 T R U T H S Hardware
 is becoming

    more like
 software. Hardware
 is hard.
  6. 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?
  7. 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
  8. Jav a S c r i p t - o

    n l y b o a r d s
  9. 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
  10. 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
  11. 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 )
  12. 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
  13. • 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
  14. 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…
  15. 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 )
  16. 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)
  17. 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 !
  18. 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.
  19. 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.
  20. 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
  21. 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
  22. 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
  23. 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
  24. C O D E T W E A K S

    Tweaks • update: 
 var lcd = 
 new jsUpmI2cLcd.SSD1308(0, 0x3C); • remove .
 setColor()
  25. 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
  26. 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