Hardware Hacking

38
Hardware Hacking by Andy “Bob The Builder” Brockhurst For the Yahoo! Developers Network and SkillsMatter

description

Talk due to be given on 1st Dec at skillsmatter in London on Hardware Hacking. An introduction on hardware hacking, what it is, how to get started. A live tutorial on the Arduino programming and examples.

Transcript of Hardware Hacking

Page 1: Hardware Hacking

Hardware Hacking

by Andy “Bob The Builder” BrockhurstFor the Yahoo! Developers Networkand SkillsMatter

Page 2: Hardware Hacking

Picture “Hardware Hacking”

by nicholasjon- flickr

Page 3: Hardware Hacking

Talk topics (in no particular order)

Introduction What is hardware hacking How to get started

Microprocessors Sensors & Switches (Hardware I/O)

The world is your mollusc Basic Circuit Theory

How to get those sensors to work

Page 4: Hardware Hacking

If anything should go wrong

Blame this next guy

Page 5: Hardware Hacking
Page 6: Hardware Hacking

Photo “Hacking”

Page 7: Hardware Hacking

What is hardware hacking Hacking

An elegant solution to a difficult problem Using a technology for something it was

not originally intended.

Page 8: Hardware Hacking

Types of hardware hacking Just hacking hardware Circuit Bending Reverse Engineering Toy Hacking SteamPunk Craft Hacking/“Making”

Page 9: Hardware Hacking

Photo: “WRT54G & NSLU2”

by lime*monkey- flickr

Page 10: Hardware Hacking

Picture “Circuit Bending”

by jamie_hladky- flickr

Page 11: Hardware Hacking

Circuit Bending Pete Edwards Musician/Hacker http://casperelectronics.com

Page 12: Hardware Hacking

Picture “Reverse Engineering”

by Micah Dowty- flickr

Page 13: Hardware Hacking

Picture “Toy Hacking”

by Vanderlin - flickr

Page 14: Hardware Hacking

Picture “Making”

Page 15: Hardware Hacking

Photo: “Steampunk”

by Balakov- flickr

Page 16: Hardware Hacking

Picture “Reverse Engineering”

by Neal Connor- flickr

Page 17: Hardware Hacking

Getting Started Arduino

Entry level microprocessor OpenSource Hardware & Software 14 digital Inputs/Outputs (6 PWM Out*) 6 analogue Inputs IDE with loads of example code Aimed at artists/hobbyists with limited

programming experience

*We’ll come to this shortly

Page 18: Hardware Hacking

Arduino (Atmega 328) 16bit Microprocessor, Embedded C 32k Flash, 2k SRAM, 1k EEPROM 16Mhz

Page 19: Hardware Hacking

Arduinos are not the only fruit Atmel Tiny (ATtiny) PIC AVR (PICAXE) Range of ARM processors FPGA

Page 20: Hardware Hacking

Arduino OpenSource Hardware

Schematics freely available Lots of “Flavours”; Diecimila, Duemilanove,

Mega, Mini, Nano, Lilypad Lots of boards for specific tasks;

Motor/servos, Autonomous Vehicles, Robotics, Autopilots, CNC (*32 makers)

Sheilds to extend functionality; Bluetooth, wifi, radio, ethernet, GPS, relays, LCD, touchscreen…

Page 21: Hardware Hacking

Arduino Initiatives Software

Processing IDE is based on Processing and Wiring

Fritzing Prototyping and circuit layout

EduWear Introducing programming and electronics

to children

Page 22: Hardware Hacking

Hardware Hacking

Let’s build some stuff!

Page 23: Hardware Hacking

by Bekathwia - flickr

Page 24: Hardware Hacking

Arduino (very) Basic I/O - Parts Setup a circuit

Arduino Breadboard LED Resistor Switch Wire

Page 25: Hardware Hacking

Arduino (very) Basic I/O - Layout

Page 26: Hardware Hacking

Arduino (very) Basic I/O - Code Define an input and an output Read the input and set the outputvoid setup() { pinMode(2, INPUT); pinMode(13, OUTPUT);}

void loop() { int switchValue = digitalRead(2); digitalWrite(13, switchValue); }

Page 27: Hardware Hacking

Take it a bit further Substitute the LED for a physical

interaction device Servo Bit more wire

Page 28: Hardware Hacking

Adding a servo

Page 29: Hardware Hacking

Update the code#include <Servo.h>

Servo myServo;int steps[] = {0,60,120,180};int currentPos = 0;

void setup() { pinMode(2, INPUT); myServo.attach(13); myServo.write(steps[0]);}

void loop() { if (HIGH == digitalRead(2)) { currentPos = (3 == currentPos) ? 0 : currentPos + 1; myServo.write(steps[currentPos]); delay(500); }}

Page 30: Hardware Hacking

Taking it further Substitute the switch for a physical

interaction device Piezo Electric transducer Can be used to sense “Knocks”

Page 31: Hardware Hacking

Wire in the piezo

Page 32: Hardware Hacking

More code updates#include <Servo.h>

Servo myServo;int steps[] = {0,60,120,180};int currentPos = 0;const int KNOCKTHRESHOLD = 100;

void setup() { myServo.attach(13); myServo.write(steps[0]);}

void loop() { if (KNOCKTHRESHOLD <= analogRead(0)) { currentPos = (3 == currentPos) ? 0 : currentPos + 1; myServo.write(steps[currentPos]); delay(500); }}

Page 33: Hardware Hacking

Tour of the software Arduino IDE Fritzing

Page 34: Hardware Hacking

Photo “Inspiration”

by pieter [iamdoom / bwrah bwrah]- flickr

Page 35: Hardware Hacking

Getting Inspiration MakeZine

http://blog.makezine.com/ Instructables

http://www.instructables.com/ Circuit-Projects

http://www.circuit-projects.com/ Tinker.it

http://www.tinker.it/

Page 36: Hardware Hacking

Where to get stuff Specialist Arduino Retailers (UK)

http://www.earthshinedesign.co.uk/ http://www.oomlout.co.uk/

Other Hardware suppliers (UK) http://www.active-robots.co.uk/ http://www.techbotics.co.uk/ http://www.technobots.co.uk/ http://www.ebay.co.uk/

Page 37: Hardware Hacking

Finding fellow hackers London Hacker Space

http://london.hackspace.org.uk/ irc://irc.freenode.net/london-hack-space

London DorkBot http://dorkbotlondon.org/

Page 38: Hardware Hacking

Thank you for listening

Where I can be found:http://kingkludge.net/http://twitter.com/b3cft

(or in the pub)