Hardware hacking on the pi; what's js got to do with it

1,667 views

Published on

Hardware Hacking using the Raspberry Pi and NodeJS with a bit of general knowledge thrown in.

Published in: Technology
1 Comment
1 Like
Statistics
Notes
  • download here link 100% working:https://app.box.com/s/olzwnk240vfm2ir8yfdw
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
1,667
On SlideShare
0
From Embeds
0
Number of Embeds
17
Actions
Shares
0
Downloads
40
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Hardware hacking on the pi; what's js got to do with it

  1. 1. HARDWARE HACKING AND THE RASPBERRY PI; WHAT'S JAVASCRIPT GOT TO DO WITH IT?
  2. 2. ALEX ROCHE @alexHacked
  3. 3. HARDWARE HACKING; WAT?
  4. 4. HARDWARE HACKING; WAT? • We take electronics and bend them to our will
  5. 5. HARDWARE HACKING; WAT? • We take electronics and bend them to our will • Can use any component, as long as it can be soldered
  6. 6. HARDWARE HACKING; WAT? • We take electronics and bend them to our will • Can use any component, as long as it can be soldered •A variety of levels of difficulty and accessibility
  7. 7. HARDWARE HACKING; WHY?
  8. 8. HARDWARE HACKING; WHY? • Prototyping concepts and systems
  9. 9. HARDWARE HACKING; WHY? • Prototyping concepts and systems • Replacing older tech that has failed
  10. 10. HARDWARE HACKING; WHY? • Prototyping concepts and systems • Replacing older tech that has failed • Making something cool
  11. 11. HARDWARE HACKING; HOW?
  12. 12. HARDWARE HACKING; HOW? •A basic knowledge of electronics is definitely helpful
  13. 13. HARDWARE HACKING; HOW? •A basic knowledge of electronics is definitely helpful • Skills such as soldering and stripping wires
  14. 14. HARDWARE HACKING; HOW? •A basic knowledge of electronics is definitely helpful • Skills such as soldering and stripping wires • GPIO pins; GPIO pins everywhere!
  15. 15. HARDWARE HACKING; HOW? •A basic knowledge of electronics is definitely helpful • Skills such as soldering and stripping wires • GPIO • No pins; GPIO pins everywhere! 'correct' or 'right' way
  16. 16. HARDWARE HACKING; HOW? •A basic knowledge of electronics is definitely helpful • Skills such as soldering and stripping wires • GPIO • No • Be pins; GPIO pins everywhere! 'correct' or 'right' way safe and have respect for electricity
  17. 17. HARDWARE HACKING; WHEN?
  18. 18. HARDWARE HACKING; WHEN? • Creating projects to react solely to electricity
  19. 19. HARDWARE HACKING; WHEN? • Creating • Using projects to react solely to electricity timing chips, resistors and circuit boards
  20. 20. HARDWARE HACKING; WHEN? • Creating • Using projects to react solely to electricity timing chips, resistors and circuit boards • Programmable micro controllers
  21. 21. HARDWARE HACKING; WHEN? • Creating • Using projects to react solely to electricity timing chips, resistors and circuit boards • Programmable micro-controllers • Micro-controllers on an integrated platform
  22. 22. ALL THE OPTIONS! •A lot of options for a lot of different skill levels
  23. 23. ALL THE OPTIONS! •A lot of options for a lot of different skill levels • Little Bits
  24. 24. ALL THE OPTIONS! •A lot of options for a lot of different skill levels • Little Bits • Makey Makey
  25. 25. ALL THE OPTIONS! •A lot of options for a lot of different skill levels • Little Bits • Makey Makey • Arduino
  26. 26. ALL THE OPTIONS! •A lot of options for a lot of different skill levels • Little Bits • Makey Makey • Arduino • Raspberry Pi
  27. 27. LITTLE BITS
  28. 28. LITTLE BITS
  29. 29. LITTLE BITS • Individual, pre-formed components
  30. 30. LITTLE BITS • Individual, pre-formed components • Held together with magnets
  31. 31. LITTLE BITS • Individual, pre-formed components • Held together with magnets • Different colours to help design a circuit
  32. 32. LITTLE BITS; A BIT USEFUL?
  33. 33. LITTLE BITS; A BIT USEFUL? • Extremely Modular
  34. 34. LITTLE BITS; A BIT USEFUL? • Extremely Modular • Incredibly Hands On
  35. 35. LITTLE BITS; A BIT USEFUL? • Extremely Modular • Incredibly Hands On • Makes exploring hardware simple and fun
  36. 36. LITTLE BITS; A BIT USEFUL? • Extremely Modular • Incredibly Hands On • Makes exploring hardware simple and fun • Best for proof of concepts and toying with new ideas
  37. 37. MAKEYMAKEY
  38. 38. MAKEYMAKEY • Plug and Play with your computer
  39. 39. MAKEYMAKEY • Plug and Play with your computer • Acts as a Keyboard
  40. 40. MAKEYMAKEY • Plug and Play with your computer • Acts as a Keyboard • Plug and clip wires in to the board to complete a circuit
  41. 41. MAKEYMAKEY; MAKES THINGS COOL?
  42. 42. MAKEYMAKEY; MAKES THINGS COOL? • Binary Input
  43. 43. MAKEYMAKEY; MAKES THINGS COOL? • Binary Input • Easy way to hack together basic interaction
  44. 44. MAKEYMAKEY; MAKES THINGS COOL? • Binary Input • Easy way to hack together basic interaction • Key Events can be used to detect interaction
  45. 45. ARDUINO
  46. 46. ARDUINO • Microcontroller circuitboard on a
  47. 47. ARDUINO • Microcontroller circuitboard • GPIO pins on a
  48. 48. ARDUINO • Microcontroller on a circuitboard • GPIO pins • Programmable over USB
  49. 49. ARDUINO • Microcontroller on a circuitboard • GPIO pins • Programmable • Can over USB run Javascript and NodeJS
  50. 50. ARDUINO; OPEN SOURCE MEANS OPEN OPTIONS
  51. 51. ARDUINO; OPEN SOURCE MEANS OPEN OPTIONS • Arduino UNO
  52. 52. ARDUINO; OPEN SOURCE MEANS OPEN OPTIONS • Arduino UNO • Arduino Mega
  53. 53. ARDUINO; OPEN SOURCE MEANS OPEN OPTIONS • Arduino UNO • Arduino Mega • Arduino Lilypad
  54. 54. ARDUINO; OPEN SOURCE MEANS OPEN OPTIONS • Arduino UNO • Arduino Mega • Arduino Lilypad • Open Source; can be reproduced by anybody with the right components
  55. 55. ARDUINO; HOW TO CODE
  56. 56. ARDUINO; HOW TO CODE • IDE based on translating simple code to C++
  57. 57. ARDUINO; HOW TO CODE • IDE based on translating simple code to C++ • BreakoutJS; Javascript Browser interactivity and Web
  58. 58. ARDUINO; HOW TO CODE • IDE based on translating simple code to C++ • BreakoutJS; Javascript and Web Browser interactivity • Johnny Five; Node based framework
  59. 59. RASPBERRY PI; TASTY!
  60. 60. RASPBERRY PI; TASTY! •A computer (and then some)
  61. 61. RASPBERRY PI; TASTY! •A computer (and then some) • GPIO pins
  62. 62. RASPBERRY PI; TASTY! •A computer (and then some) • GPIO • Has pins all the hardware needed for a computer onboard
  63. 63. RASPBERRY PI; TASTY! •A computer (and then some) • GPIO pins • Has all the hardware needed for a computer onboard • Runs a boatload of operating systems
  64. 64. RASPBERRY PI; TASTY! •A computer (and then some) • GPIO pins • Has all the hardware needed for a computer onboard • Runs a boatload of operating systems • GPIO pins are easily addressable
  65. 65. RASPBERRY PI; CHOICES!
  66. 66. RASPBERRY PI; CHOICES! • Two Different Types
  67. 67. RASPBERRY PI; CHOICES! • Two Different Types • Model A
  68. 68. RASPBERRY PI; CHOICES! • Two Different Types • Model A • Model B
  69. 69. RASPBERRY PI; MODEL A
  70. 70. RASPBERRY PI; MODEL A • Single USB
  71. 71. RASPBERRY PI; MODEL A • Single USB • 256MB RAM
  72. 72. RASPBERRY PI; MODEL A • Single USB • 256MB • Audio RAM & RCA video output
  73. 73. RASPBERRY PI; MODEL A • Single USB • 256MB RAM • Audio & RCA video output • HDMI output
  74. 74. RASPBERRY PI; MODEL A • Single USB • 256MB RAM • Audio & RCA video output • HDMI output • 26 GPIO pins
  75. 75. RASPBERRY PI; MODEL A • Single USB • 256MB RAM • Audio & RCA video output • HDMI output • 26 GPIO pins • Runs Minecraft!
  76. 76. RASPBERRY PI; MODEL B
  77. 77. RASPBERRY PI; MODEL B •2 USB Connectors
  78. 78. RASPBERRY PI; MODEL B •2 USB Connectors • 512MB RAM
  79. 79. RASPBERRY PI; MODEL B •2 USB Connectors • 512MB RAM • Ethernet Jack
  80. 80. RASPBERRY PI; MODEL B •2 USB Connectors • 512MB RAM • Ethernet • 34 Jack GPIO pins
  81. 81. RASPBERRY PI; MODEL B •2 USB Connectors • 512MB RAM • Ethernet • 34 Jack GPIO pins • Additional 8 are mostly unused; supply power and ground
  82. 82. RASPBERRY PI; GPIO MAPPING
  83. 83. RASPBERRY PI; GPIO MAPPING
  84. 84. RASPBERRY PI; GPIO MAPPING
  85. 85. RASPBERRY PI; WHY?
  86. 86. RASPBERRY PI; WHY? • More Processing Power
  87. 87. RASPBERRY PI; WHY? • More Processing Power • Onboard Storage
  88. 88. RASPBERRY PI; WHY? • More Processing Power • Onboard Storage • Freedom of Language Choice
  89. 89. RASPBERRY PI; WHY? • More Processing Power • Onboard Storage • Freedom of Language Choice • Easily configured Internet Access
  90. 90. RASPBERRY PI; WHY? • More Processing Power • Onboard Storage • Freedom of Language Choice • Easily configured Internet Access • Runs any code you write for it on the board instead of tethered to a computer
  91. 91. RASPBERRY PI; WHY NOT? • Less battery life than an Arduino
  92. 92. RASPBERRY PI; WHY NOT? • Less battery life than an Arduino • Can be cumbersome to set up and program
  93. 93. RASPBERRY PI; WHY NOT? • Less battery life than an Arduino • Can be cumbersome to set up and program • Doesn’t have as much of a support for shields
  94. 94. SHIELDS?
  95. 95. SHIELDS? • Pre created circuit boards that extend functionality
  96. 96. SHIELDS? • Pre created circuit boards that extend functionality • Can use multiple shields at once ...
  97. 97. SHIELDS? • Pre created circuit boards that extend functionality • Can use multiple shields at once ... • ... though like using multiple of anything at once, take care.
  98. 98. NODE; WHAT IS IT?
  99. 99. NODE; WHAT IS IT? •A familiar flavour of Javascript; people already know it!
  100. 100. NODE; WHAT IS IT? •A familiar flavour of Javascript; people already know it! • Non Blocking I/O
  101. 101. NODE; WHAT IS IT? •A familiar flavour of Javascript; people already know it! • Non Blocking I/O • Event Driven using callbacks
  102. 102. NODE; WHAT IS IT? •A familiar flavour of Javascript; people already know it! • Non Blocking I/O • Event Driven using callbacks • Operating System Agnostic (mostly)
  103. 103. NODE; WHY IS IT COOL?
  104. 104. NODE; WHY IS IT COOL? • Incorporates Google’s V8 Engine for speed
  105. 105. NODE; WHY IS IT COOL? • Incorporates • Has Google’s V8 Engine for speed some really fun functions
  106. 106. NODE; WHY IS IT COOL? • Incorporates • Has Google’s V8 Engine for speed some really fun functions • Crypto, OS, FS
  107. 107. NODE; WHY IS IT COOL? • Incorporates • Has • Google’s V8 Engine for speed some really fun functions Crypto, OS, FS • Has a massive amount of external libraries to augment it
  108. 108. NODE; WHY IS IT COOL? • Incorporates • Has • some really fun functions Crypto, OS, FS • Has •A Google’s V8 Engine for speed a massive amount of external libraries to augment it server side language front end developers can write!
  109. 109. NODE; HOW TO INSTALL? LINUX
  110. 110. NODE; HOW TO INSTALL? LINUX > wget http://nodejs.org/dist/v.0.8.11/nodev0.8.11.tar.gz > > > > > tar -zxf node-v0.8.11.tar.gz cd node-v0.8.11 ./configure make sudo make install
  111. 111. NODE; HOW TO INSTALL? MAC & WINDOWS
  112. 112. NODE; HOW TO INSTALL? MAC & WINDOWS • Much more simple and straightforward than Linux
  113. 113. NODE; HOW TO INSTALL? MAC & WINDOWS • Much more simple and straightforward than Linux • Go get the installer from nodejs.org/download/
  114. 114. NODE; HOW TO INSTALL? MAC & WINDOWS • Much more simple and straightforward than Linux • Go get the installer from nodejs.org/download/ • No, really. Download it from there and install it. Job done.
  115. 115. NODE; HOW TO INSTALL? MAC & WINDOWS • Much more simple and straightforward than Linux • Go get the installer from nodejs.org/download/ • No, really. Download it from there and install it. Job done.
  116. 116. NODE; HOW TO USE?
  117. 117. NODE; HOW TO USE? • Write JavaScript!
  118. 118. NODE; HOW TO USE? • Write JavaScript! • Watch out for the PHP-esque require(“”); though!
  119. 119. NODE; HOW TO USE? • Write JavaScript! • Watch out for the PHP-esque require(“”); though! • Make use of the inbuilt libraries in NodeJS
  120. 120. NPM; NOT PROBLEMATIC, MOSTLY
  121. 121. NPM; NOT PROBLEMATIC, MOSTLY • Nodes inbuilt library management tool
  122. 122. NPM; NOT PROBLEMATIC, MOSTLY • Nodes inbuilt library management tool • Has its own website listing all of the modules
  123. 123. NPM; NOT PROBLEMATIC, MOSTLY • Nodes inbuilt library management tool • Has its own website listing all of the modules • Makes it incredibly easy to install modules
  124. 124. NPM; HOW TO USE
  125. 125. NPM; HOW TO USE • It all starts with npm
  126. 126. NPM; HOW TO USE • It all starts with npm • Different Keywords; https://npmjs.org/docs
  127. 127. NPM; HOW TO USE • It all starts with npm • Different • Most Keywords; https://npmjs.org/docs useful are install and update
  128. 128. NPM; HOW TO USE • It all starts with npm • Different Keywords; https://npmjs.org/docs • Most useful are install and update • npm install || npm update
  129. 129. NPM; INSTALLING A MODULE
  130. 130. NPM; INSTALLING A MODULE • Find the package you want to install on the npm site
  131. 131. NPM; INSTALLING A MODULE • Find the package you want to install on the npm site • Run npm install gpio to install the package
  132. 132. NPM; INSTALLING A MODULE • Find the package you want to install on the npm site • Run npm install gpio to install the package • -g flag installs globally instead of locally for command line use
  133. 133. NPM; INSTALLING A MODULE • Find the package you want to install on the npm site • Run npm install gpio to install the package • -g flag installs globally instead of locally for command line use • require(“gpio”); in your project
  134. 134. NPM; INSTALLING A MODULE • Find the package you want to install on the npm site • Run npm install gpio to install the package • -g flag installs globally instead of locally for command line use • require(“gpio”); • npm in your project packages need to be installed in each project’s folder you intend to use them in
  135. 135. BAKING A RASPBERRY PI
  136. 136. BAKING A PI • We have a lot of choices for the operating system
  137. 137. BAKING A PI • We have a lot of choices for the operating system • Linux
  138. 138. BAKING A PI • We have a lot of choices for the operating system • Linux • RISC
  139. 139. BAKING A PI • We have a lot of choices for the operating system • Linux • RISC • Android
  140. 140. BAKING A PI • We have a lot of choices for the operating system • Linux • RISC • Android • FirefoxOS
  141. 141. COOKING THE FILLING •ç
  142. 142. COOKING THE FILLING • Windows • Win32DiskImager
  143. 143. COOKING THE FILLING • Windows • Win32DiskImager • Mac • RPI sd card builder, PiWriter, Pi Filler
  144. 144. COOKING THE FILLING • Windows • Win32DiskImager • Mac • RPI sd card builder, PiWriter, Pi Filler • Linux • ImageWriter
  145. 145. COOKING THE FILLING • Windows • Win32DiskImager • Mac • RPI sd card builder, PiWriter, Pi Filler • Linux • ImageWriter
  146. 146. COOKING THE FILLING • Windows • Win32DiskImager • Mac • RPI sd card builder, PiWriter, Pi Filler • Linux • ImageWriter
  147. 147. CUTTING IN TO THE PI
  148. 148. CUTTING IN TO THE PI • First off, we install Adafruit’s Occidentalis distribution
  149. 149. CUTTING IN TO THE PI • First off, we install Adafruit’s Occidentalis distribution • We SSH in to the Raspberry Pi
  150. 150. CUTTING IN TO THE PI • First off, we install Adafruit’s Occidentalis distribution • We SSH in to the Raspberry Pi • We connect it to a monitor with keyboard and mouse
  151. 151. CUTTING IN TO THE PI; SSH
  152. 152. CUTTING IN TO THE PI; SSH • Power it up!
  153. 153. CUTTING IN TO THE PI; SSH • Power • Plug it up! an Ethernet cable in to your Pi and your Router
  154. 154. CUTTING IN TO THE PI; SSH • Power • Plug • Run it up! an Ethernet cable in to your Pi and your Router ssh raspberrypi.local on your computer to get to the Pi
  155. 155. CUTTING IN TO THE PI; SSH • Power • Plug it up! an Ethernet cable in to your Pi and your Router • Run ssh raspberrypi.local on your computer to get to the Pi • Alternatively log in to your router and get the IP of the Pi from there; ssh pi@<ip_of_pi> . Use the password “raspberry”
  156. 156. WIRED IS BORING, RIGHT?!
  157. 157. LETS GO WIRELESS!
  158. 158. CUTTING THE PI LOOSE
  159. 159. CUTTING THE PI LOOSE • Run sudo nano /etc/ network/interfaces
  160. 160. CUTTING THE PI LOOSE • Run sudo nano /etc/ network/interfaces • Delete file the contents of the
  161. 161. CUTTING THE PI LOOSE > auto lo > iface lo inet loopback > iface eth0 inet dhcp > allow-hotplug wlan0 > auto wlan0 > iface wlan0 inet dhcp >    wpa-ssid "ssid" >    wpa-psk "password" • Run sudo nano /etc/ network/interfaces • Delete the contents of the file • <- Replace it with this
  162. 162. CUTTING THE PI LOOSE > auto lo > iface lo inet loopback > iface eth0 inet dhcp > allow-hotplug wlan0 > auto wlan0 • Run sudo nano /etc/ network/interfaces • Delete the contents of the file • <- > iface wlan0 inet dhcp >    wpa-ssid "ssid" >    wpa-psk "password" • Replace Replace it with this SSID and PASSWORD
  163. 163. BLOWING RASPBERRIES
  164. 164. BLOWING RASPBERRIES GPIO API; https://npmjs.org/package/ gpio Manual Setting and Getting
  165. 165. BLOWING RASPBERRIES GPIO Johnny-Five API; https://npmjs.org/package/ gpio API; https://github.com/ rwaldron/johnny-five/wiki Manual Setting and Getting for Raspberry Pi Function Based System for Arduino
  166. 166. BLOWING RASPBERRIES; SETTING UP A CONTEXT
  167. 167. BLOWING RASPBERRIES; SETTING UP A CONTEXT GPIO > var gpio = require("gpio"); > >/* Calling export with a pin >number will export that header >and return a gpio header >instance*/ > > var gpio4 = gpio.export(4, { >      direction: 'out', >    interval: 200, >     ready: function() { >    } >});
  168. 168. BLOWING RASPBERRIES; SETTING UP A CONTEXT GPIO Johnny-Five > var gpio = require("gpio"); > >/* Calling export with a pin >number will export that header >and return a gpio header >instance*/ > > var gpio4 = gpio.export(4, { >      direction: 'out', >    interval: 200, >     ready: function() { >    } >}); > var five = require("johnnyfive"), board, led; > > board = new five.Board(); > >board.on("ready", function() { });
  169. 169. BLOWING RASPBERRIES; MAKING A LIGHT BLINK
  170. 170. BLOWING RASPBERRIES; MAKING A LIGHT BLINK GPIO >Var strobeTimer = setInterval(function() { > gpio4.set();          > setTimeout( > function(){ > gpio4.reset(); > }, 200); > }, 400); >/*Can also pass a number in to >the >set function.*/
  171. 171. BLOWING RASPBERRIES; MAKING A LIGHT BLINK GPIO Johnny-Five >  /* Create a standard `led` >hardware instance*/ >  Var led = new five.Led(13); > >  /* "strobe" the led in 100ms >on-off phases*/ >  led.strobe( 100 ); >Var strobeTimer = setInterval(function() { > gpio4.set();          > setTimeout( > function(){ > gpio4.reset(); > }, 200); > }, 400); >/*Can also pass a number in to >the >set function.*/
  172. 172. BLOWING RASPBERRIES; GETTING VALUES
  173. 173. BLOWING RASPBERRIES; GETTING VALUES GPIO >var gpio = require("gpio"); >var gpio4 = gpio.export(4, { >   direction: "in", >   ready: function() { > Console.log(gpio4.value >   } >});
  174. 174. BLOWING RASPBERRIES; GETTING VALUES GPIO Johnny-Five >var gpio = require("gpio"); >var gpio4 = gpio.export(4, { >   direction: "in", >   ready: function() { > Console.log(gpio4.value >   } >}); >new five.Pin(13).query( >function(state) { >  console.log(state); >});
  175. 175. BLOWING RASPBERRIES; SETTING VALUES
  176. 176. BLOWING RASPBERRIES; SETTING VALUES GPIO > gpio4.set(function() >{ console.log(gpio4.value); >});
  177. 177. BLOWING RASPBERRIES; SETTING VALUES GPIO > gpio4.set(function() >{ console.log(gpio4.value); >}); Johnny-Five Nothing explicit; is accomplished by passing values straight in to the functions
  178. 178. FINAL HINTS AND TIPS • Once client connected so you can SSH in to it, use a file transfer
  179. 179. FINAL HINTS AND TIPS • Once connected so you can SSH in to it, use a file transfer client • Helpful the PI if the GPIO pins are labeled using the paper overlay for
  180. 180. FINAL HINTS AND TIPS • Once connected so you can SSH in to it, use a file transfer client • Helpful if the GPIO pins are labeled using the paper overlay for the PI • Get a ribbon cord for the Pi; will make your life easier.
  181. 181. HE’S STILL NOT FINISHED? • Not everything has to be written in NodeJS
  182. 182. HE’S STILL NOT FINISHED? • Not everything has to be written in NodeJS • Is, however, an developers accessible starting point for front end
  183. 183. HE’S STILL NOT FINISHED? • Not everything has to be written in NodeJS • Is, however, an accessible starting point for front end developers • Projects don’t need to be in the same language
  184. 184. HE’S STILL NOT FINISHED? • Not everything has to be written in NodeJS • Is, however, an accessible starting point for front end developers • Projects don’t need to be in the same language • Important that what you’ve written works
  185. 185. MAYBE HE NEARLY IS? • Don’t be afraid; there’s always help at hand!
  186. 186. MAYBE HE NEARLY IS? • Don’t be afraid; there’s always help at hand! • Don’t expect to not learn anything during the project!
  187. 187. MAYBE HE NEARLY IS? • Don’t be afraid; there’s always help at hand! • Don’t expect to not learn anything during the project! • Have fun with your project!
  188. 188. MAYBE HE NEARLY IS? • Don’t be afraid; there’s always help at hand! • Don’t expect to not learn anything during the project! • Have fun with your project! • Be Careful!
  189. 189. THANK YOU!
  190. 190. RESOURCES • Node; nodejs.org/downloads/ • NPM; npmjs.org • NodeSchool; nodeschool.io • Adafruit Industries; http://learn.adafruit.com/category/learnraspberry-pi • RS-Components; uk.rs-online.com • Farnell; uk.farnell.com

×