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

190
HARDWARE HACKING AND THE RASPBERRY PI; WHAT'S JAVASCRIPT GOT TO DO WITH IT?

Upload: alexander-roche

Post on 28-Jan-2015

108 views

Category:

Technology


1 download

DESCRIPTION

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

TRANSCRIPT

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

HARDWARE HACKING AND THE RASPBERRY PI; WHAT'S JAVASCRIPT GOT TO DO WITH IT?

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

ALEX ROCHE@alexHacked

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

HARDWARE HACKING; WAT?

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

HARDWARE HACKING; WAT?

• We take electronics and bend them to our will

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

HARDWARE HACKING; WAT?

• We take electronics and bend them to our will

• Can use any component, as long as it can be soldered

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

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

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

HARDWARE HACKING; WHY?

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

HARDWARE HACKING; WHY?

• Prototyping concepts and systems

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

HARDWARE HACKING; WHY?

• Prototyping concepts and systems

• Replacing older tech that has failed

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

HARDWARE HACKING; WHY?

• Prototyping concepts and systems

• Replacing older tech that has failed

• Making something cool

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

HARDWARE HACKING; HOW?

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

HARDWARE HACKING; HOW?

• A basic knowledge of electronics is definitely helpful

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

HARDWARE HACKING; HOW?

• A basic knowledge of electronics is definitely helpful

• Skills such as soldering and stripping wires

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

HARDWARE HACKING; HOW?

• A basic knowledge of electronics is definitely helpful

• Skills such as soldering and stripping wires

• GPIO pins; GPIO pins everywhere!

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

HARDWARE HACKING; HOW?

• A basic knowledge of electronics is definitely helpful

• Skills such as soldering and stripping wires

• GPIO pins; GPIO pins everywhere!

• No 'correct' or 'right' way

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

HARDWARE HACKING; HOW?

• A basic knowledge of electronics is definitely helpful

• Skills such as soldering and stripping wires

• GPIO pins; GPIO pins everywhere!

• No 'correct' or 'right' way

• Be safe and have respect for electricity

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

HARDWARE HACKING; WHEN?

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

HARDWARE HACKING; WHEN?

• Creating projects to react solely to electricity

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

HARDWARE HACKING; WHEN?

• Creating projects to react solely to electricity

• Using timing chips, resistors and circuit boards

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

HARDWARE HACKING; WHEN?

• Creating projects to react solely to electricity

• Using timing chips, resistors and circuit boards

• Programmable micro controllers

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

HARDWARE HACKING; WHEN?

• Creating projects to react solely to electricity

• Using timing chips, resistors and circuit boards

• Programmable micro-controllers

• Micro-controllers on an integrated platform

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

ALL THE OPTIONS!

• A lot of options for a lot of different skill levels

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

ALL THE OPTIONS!

• A lot of options for a lot of different skill levels

• Little Bits

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

ALL THE OPTIONS!

• A lot of options for a lot of different skill levels

• Little Bits

• Makey Makey

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

ALL THE OPTIONS!

• A lot of options for a lot of different skill levels

• Little Bits

• Makey Makey

• Arduino

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

ALL THE OPTIONS!

• A lot of options for a lot of different skill levels

• Little Bits

• Makey Makey

• Arduino

• Raspberry Pi

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

LITTLE BITS

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

LITTLE BITS

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

LITTLE BITS

• Individual, pre-formed components

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

LITTLE BITS

• Individual, pre-formed components

• Held together with magnets

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

LITTLE BITS

• Individual, pre-formed components

• Held together with magnets

• Different colours to help design a circuit

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

LITTLE BITS; A BIT USEFUL?

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

LITTLE BITS; A BIT USEFUL?

• Extremely Modular

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

LITTLE BITS; A BIT USEFUL?

• Extremely Modular

• Incredibly Hands On

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

LITTLE BITS; A BIT USEFUL?

• Extremely Modular

• Incredibly Hands On

• Makes exploring hardware simple and fun

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

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

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

MAKEYMAKEY

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

MAKEYMAKEY

• Plug and Play with your computer

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

MAKEYMAKEY

• Plug and Play with your computer

• Acts as a Keyboard

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

MAKEYMAKEY

• Plug and Play with your computer

• Acts as a Keyboard

• Plug and clip wires in to the board to complete a circuit

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

MAKEYMAKEY; MAKES THINGS COOL?

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

MAKEYMAKEY; MAKES THINGS COOL?

• Binary Input

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

MAKEYMAKEY; MAKES THINGS COOL?

• Binary Input

• Easy way to hack together basic interaction

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

MAKEYMAKEY; MAKES THINGS COOL?

• Binary Input

• Easy way to hack together basic interaction

• Key Events can be used to detect interaction

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

ARDUINO

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

ARDUINO

• Microcontroller on a circuitboard

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

ARDUINO

• Microcontroller on a circuitboard

• GPIO pins

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

ARDUINO

• Microcontroller on a circuitboard

• GPIO pins

• Programmable over USB

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

ARDUINO

• Microcontroller on a circuitboard

• GPIO pins

• Programmable over USB

• Can run Javascript and NodeJS

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

ARDUINO; OPEN SOURCE MEANS OPEN OPTIONS

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

ARDUINO; OPEN SOURCE MEANS OPEN OPTIONS

• Arduino UNO

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

ARDUINO; OPEN SOURCE MEANS OPEN OPTIONS

• Arduino UNO

• Arduino Mega

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

ARDUINO; OPEN SOURCE MEANS OPEN OPTIONS

• Arduino UNO

• Arduino Mega

• Arduino Lilypad

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

ARDUINO; OPEN SOURCE MEANS OPEN OPTIONS

• Arduino UNO

• Arduino Mega

• Arduino Lilypad

• Open Source; can be reproduced by anybody with the right components

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

ARDUINO; HOW TO CODE

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

ARDUINO; HOW TO CODE

• IDE based on translating simple code to C++

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

ARDUINO; HOW TO CODE

• IDE based on translating simple code to C++

• BreakoutJS; Javascript and Web Browser interactivity

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

ARDUINO; HOW TO CODE

• IDE based on translating simple code to C++

• BreakoutJS; Javascript and Web Browser interactivity

• Johnny Five; Node based framework

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

RASPBERRY PI; TASTY!

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

RASPBERRY PI; TASTY!

• A computer (and then some)

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

RASPBERRY PI; TASTY!

• A computer (and then some)

• GPIO pins

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

RASPBERRY PI; TASTY!

• A computer (and then some)

• GPIO pins

• Has all the hardware needed for a computer onboard

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

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

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

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

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

RASPBERRY PI; CHOICES!

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

RASPBERRY PI; CHOICES!

• Two Different Types

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

RASPBERRY PI; CHOICES!

• Two Different Types

• Model A

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

RASPBERRY PI; CHOICES!

• Two Different Types

• Model A

• Model B

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

RASPBERRY PI; MODEL A

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

RASPBERRY PI; MODEL A

• Single USB

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

RASPBERRY PI; MODEL A

• Single USB

• 256MB RAM

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

RASPBERRY PI; MODEL A

• Single USB

• 256MB RAM

• Audio & RCA video output

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

RASPBERRY PI; MODEL A

• Single USB

• 256MB RAM

• Audio & RCA video output

• HDMI output

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

RASPBERRY PI; MODEL A

• Single USB

• 256MB RAM

• Audio & RCA video output

• HDMI output

• 26 GPIO pins

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

RASPBERRY PI; MODEL A

• Single USB

• 256MB RAM

• Audio & RCA video output

• HDMI output

• 26 GPIO pins

• Runs Minecraft!

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

RASPBERRY PI; MODEL B

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

RASPBERRY PI; MODEL B

• 2 USB Connectors

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

RASPBERRY PI; MODEL B

• 2 USB Connectors

• 512MB RAM

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

RASPBERRY PI; MODEL B

• 2 USB Connectors

• 512MB RAM

• Ethernet Jack

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

RASPBERRY PI; MODEL B

• 2 USB Connectors

• 512MB RAM

• Ethernet Jack

• 34 GPIO pins

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

RASPBERRY PI; MODEL B

• 2 USB Connectors

• 512MB RAM

• Ethernet Jack

• 34 GPIO pins

• Additional 8 are mostly unused; supply power and ground

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

RASPBERRY PI; GPIO MAPPING

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

RASPBERRY PI; GPIO MAPPING

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

RASPBERRY PI; GPIO MAPPING

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

RASPBERRY PI; WHY?

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

RASPBERRY PI; WHY?

• More Processing Power

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

RASPBERRY PI; WHY?

• More Processing Power

• Onboard Storage

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

RASPBERRY PI; WHY?

• More Processing Power

• Onboard Storage

• Freedom of Language Choice

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

RASPBERRY PI; WHY?

• More Processing Power

• Onboard Storage

• Freedom of Language Choice

• Easily configured Internet Access

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

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

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

RASPBERRY PI; WHY NOT?

• Less battery life than an Arduino

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

RASPBERRY PI; WHY NOT?

• Less battery life than an Arduino

• Can be cumbersome to set up and program

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

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

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

SHIELDS?

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

SHIELDS?

• Pre created circuit boards that extend functionality

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

SHIELDS?

• Pre created circuit boards that extend functionality

• Can use multiple shields at once ...

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

SHIELDS?

• Pre created circuit boards that extend functionality

• Can use multiple shields at once ...

• ... though like using multiple of anything at once, take care.

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

NODE; WHAT IS IT?

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

NODE; WHAT IS IT?

• A familiar flavour of Javascript; people already know it!

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

NODE; WHAT IS IT?

• A familiar flavour of Javascript; people already know it!

• Non Blocking I/O

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

NODE; WHAT IS IT?

• A familiar flavour of Javascript; people already know it!

• Non Blocking I/O

• Event Driven using callbacks

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

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)

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

NODE; WHY IS IT COOL?

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

NODE; WHY IS IT COOL?

• Incorporates Google’s V8 Engine for speed

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

NODE; WHY IS IT COOL?

• Incorporates Google’s V8 Engine for speed

• Has some really fun functions

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

NODE; WHY IS IT COOL?

• Incorporates Google’s V8 Engine for speed

• Has some really fun functions

• Crypto, OS, FS

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

NODE; WHY IS IT COOL?

• Incorporates Google’s V8 Engine for speed

• Has some really fun functions

• Crypto, OS, FS

• Has a massive amount of external libraries to augment it

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

NODE; WHY IS IT COOL?

• Incorporates Google’s V8 Engine for speed

• Has some really fun functions

• Crypto, OS, FS

• Has a massive amount of external libraries to augment it

• A server side language front end developers can write!

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

NODE; HOW TO INSTALL? LINUX

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

NODE; HOW TO INSTALL? LINUX

> wget http://nodejs.org/dist/v.0.8.11/node-v0.8.11.tar.gz > tar -zxf node-v0.8.11.tar.gz > cd node-v0.8.11 > ./configure > make > sudo make install

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

NODE; HOW TO INSTALL? MAC & WINDOWS

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

NODE; HOW TO INSTALL? MAC & WINDOWS

• Much more simple and straightforward than Linux

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

NODE; HOW TO INSTALL? MAC & WINDOWS

• Much more simple and straightforward than Linux

• Go get the installer from nodejs.org/download/

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

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.

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

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.

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

NODE; HOW TO USE?

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

NODE; HOW TO USE?

• Write JavaScript!

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

NODE; HOW TO USE?

• Write JavaScript!

• Watch out for the PHP-esque require(“”); though!

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

NODE; HOW TO USE?

• Write JavaScript!

• Watch out for the PHP-esque require(“”); though!

• Make use of the inbuilt libraries in NodeJS

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

NPM; NOT PROBLEMATIC, MOSTLY

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

NPM; NOT PROBLEMATIC, MOSTLY

• Nodes inbuilt library management tool

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

NPM; NOT PROBLEMATIC, MOSTLY

• Nodes inbuilt library management tool

• Has its own website listing all of the modules

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

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

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

NPM; HOW TO USE

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

NPM; HOW TO USE

• It all starts with npm

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

NPM; HOW TO USE

• It all starts with npm

• Different Keywords; https://npmjs.org/docs

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

NPM; HOW TO USE

• It all starts with npm

• Different Keywords; https://npmjs.org/docs

• Most useful are install and update

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

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

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

NPM; INSTALLING A MODULE

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

NPM; INSTALLING A MODULE

• Find the package you want to install on the npm site

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

NPM; INSTALLING A MODULE

• Find the package you want to install on the npm site

• Run npm install gpio to install the package

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

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

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

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

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

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

• npm packages need to be installed in each project’s folder you intend to use them in

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

BAKING A RASPBERRY PI

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

BAKING A PI

• We have a lot of choices for the operating system

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

BAKING A PI

• We have a lot of choices for the operating system

• Linux

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

BAKING A PI

• We have a lot of choices for the operating system

• Linux

• RISC

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

BAKING A PI

• We have a lot of choices for the operating system

• Linux

• RISC

• Android

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

BAKING A PI

• We have a lot of choices for the operating system

• Linux

• RISC

• Android

• FirefoxOS

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

COOKING THE FILLING

• ç

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

COOKING THE FILLING

• Windows

• Win32DiskImager

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

COOKING THE FILLING

• Windows

• Win32DiskImager

• Mac

• RPI sd card builder, PiWriter, Pi Filler

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

COOKING THE FILLING

• Windows

• Win32DiskImager

• Mac

• RPI sd card builder, PiWriter, Pi Filler

• Linux

• ImageWriter

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

COOKING THE FILLING

• Windows

• Win32DiskImager

• Mac

• RPI sd card builder, PiWriter, Pi Filler

• Linux

• ImageWriter

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

COOKING THE FILLING

• Windows

• Win32DiskImager

• Mac

• RPI sd card builder, PiWriter, Pi Filler

• Linux

• ImageWriter

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

CUTTING IN TO THE PI

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

CUTTING IN TO THE PI

• First off, we install Adafruit’s Occidentalis distribution

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

CUTTING IN TO THE PI

• First off, we install Adafruit’s Occidentalis distribution

• We SSH in to the Raspberry Pi

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

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

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

CUTTING IN TO THE PI; SSH

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

CUTTING IN TO THE PI; SSH

• Power it up!

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

CUTTING IN TO THE PI; SSH

• Power it up!

• Plug an Ethernet cable in to your Pi and your Router

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

CUTTING IN TO THE PI; SSH

• Power it up!

• Plug an Ethernet cable in to your Pi and your Router

• Run ssh raspberrypi.local on your computer to get to the Pi

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

CUTTING IN TO THE PI; SSH

• Power it up!

• Plug 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”

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

WIRED IS BORING, RIGHT?!

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

LETS GO WIRELESS!

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

CUTTING THE PI LOOSE

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

CUTTING THE PI LOOSE

• Run sudo nano /etc/network/interfaces

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

CUTTING THE PI LOOSE

• Run sudo nano /etc/network/interfaces

• Delete the contents of the file

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

CUTTING THE PI LOOSE

• Run sudo nano /etc/network/interfaces

• Delete the contents of the file

• <- Replace it with this

> 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"

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

CUTTING THE PI LOOSE

• Run sudo nano /etc/network/interfaces

• Delete the contents of the file

• <- Replace it with this

• Replace SSID and PASSWORD

> 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"

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

BLOWING RASPBERRIES

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

BLOWING RASPBERRIES

GPIO

API; https://npmjs.org/package/gpio

Manual Setting and Getting

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

BLOWING RASPBERRIES

Johnny-Five

API; https://github.com/rwaldron/johnny-five/wiki

Function Based System for Arduino

GPIO

API; https://npmjs.org/package/gpio

Manual Setting and Getting for Raspberry Pi

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

BLOWING RASPBERRIES; SETTING UP A CONTEXT

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

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() { >    } >});

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

BLOWING RASPBERRIES; SETTING UP A CONTEXT

Johnny-Five > var five = require("johnny- five"), board, led; > > board = new five.Board(); > >board.on("ready", function() { });

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() { >    } >});

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

BLOWING RASPBERRIES; MAKING A LIGHT BLINK

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

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.*/

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

BLOWING RASPBERRIES; MAKING A LIGHT BLINK

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 );

GPIO >Var strobeTimer = setInterval(function() { > gpio4.set();          > setTimeout( > function(){ > gpio4.reset(); > }, 200); > }, 400); >/*Can also pass a number in to >the >set function.*/

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

BLOWING RASPBERRIES; GETTING VALUES

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

BLOWING RASPBERRIES; GETTING VALUES

GPIO >var gpio = require("gpio"); >var gpio4 = gpio.export(4, { >   direction: "in", >   ready: function() { > Console.log(gpio4.value >   } >});

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

BLOWING RASPBERRIES; GETTING VALUES

Johnny-Five >new five.Pin(13).query( >function(state) { >  console.log(state); >});

GPIO >var gpio = require("gpio"); >var gpio4 = gpio.export(4, { >   direction: "in", >   ready: function() { > Console.log(gpio4.value >   } >});

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

BLOWING RASPBERRIES; SETTING VALUES

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

BLOWING RASPBERRIES; SETTING VALUES

GPIO > gpio4.set(function() >{ console.log(gpio4.value); >});

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

BLOWING RASPBERRIES; SETTING VALUES

Johnny-Five Nothing explicit; is accomplished by passing values straight in to the functions

GPIO > gpio4.set(function() >{ console.log(gpio4.value); >});

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

FINAL HINTS AND TIPS

• Once connected so you can SSH in to it, use a file transfer client

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

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

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

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.

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

HE’S STILL NOT FINISHED?

• Not everything has to be written in NodeJS

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

HE’S STILL NOT FINISHED?

• Not everything has to be written in NodeJS

• Is, however, an accessible starting point for front end developers

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

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

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

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

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

MAYBE HE NEARLY IS?

• Don’t be afraid; there’s always help at hand!

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

MAYBE HE NEARLY IS?

• Don’t be afraid; there’s always help at hand!

• Don’t expect to not learn anything during the project!

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

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!

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

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!

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

THANK YOU!

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

RESOURCES

• Node; nodejs.org/downloads/

• NPM; npmjs.org

• NodeSchool; nodeschool.io

• Adafruit Industries; http://learn.adafruit.com/category/learn-raspberry-pi

• RS-Components; uk.rs-online.com

• Farnell; uk.farnell.com