how to hack electronics

Download How to hack electronics

Post on 01-Nov-2014

743 views

Category:

Devices & Hardware

6 download

Embed Size (px)

DESCRIPTION

In this session IOT expert Bob Gallup walked us through the basics of electronics and taught us how to do some basic wiring and programming on an Adafruit Trinket micro processor.

TRANSCRIPT

  • 1. Drawing is putting a line round an idea ~Henri Matisse
  • 2. Hacking is giving form to an idea
  • 3. Hack to Learn
  • 4. Hack to Communicate
  • 5. Hack to Do
  • 6. Hack to Do Think
  • 7. How to Hack Electronics PLANNING-NESS 2014
  • 8. Hi. Im Robert Gallup
  • 9. Agenda Mad Cap First Hacks Electricity + Electronics Hacking Switches + Knobs + Smart LEDs Project? Wrap Up
  • 10. Feel Free to Wander
  • 11. ?
  • 12. Your Hackers Kit E STEALTH CASE BREADBOARD RESISTOR LED SMART LED JUMPER WIRES BUTTON KNOB TRINKET
  • 13. Microcontroller
  • 14. Put the Trinket in the Breadboard >
  • 15. Connect the Trinket to your Computer > Power Indicator Glowing at First
  • 16. Download Software > http://www.robertgallup.com/download/planningness2014-mac.zip Unzip Arduino Software Note: There are also downloads for -windows, and -linux
  • 17. Start Arduino
  • 18. Mac OS X: Security Settings > 1 2 3 4 Open Preferences Unlock, and change Allow apps to Anywhere Run IMPORTANT: Reset security settings
  • 19. Configure the Software for Your Board >
  • 20. Configure the Programmer >
  • 21. Add the Planning-ness Examples > 1 2 Select planningness2014 in the Libraries folder from the class software download
  • 22. If it works, >
  • 23. ?
  • 24. Load the LEDBlink Example >
  • 25. The Sketch Window > Sketch (program)
  • 26. Run the Sketch on your Trinket > 1 2 Press Reset Press the Run button LED glows
  • 27. Wait. What?!
  • 28. The Blink > Blinking
  • 29. Sketch Structure (Recipe) E // S void setup() { pinMode(1, OUTPUT); } ! // Loop void loop() { digitalWrite(1, HIGH); delay(500); digitalWrite(1, LOW); delay(500); } Comment Statements
  • 30. Sketch Walkthrough (See the Comments) E // Setup runs once at the beginning void setup() { pinMode(1, OUTPUT); // Pin #1 is output } ! // Loop runs over and over again forever void loop() { digitalWrite(1, HIGH); // turn the LED on delay(1000); // wait for a second digitalWrite(1, LOW); // turn the LED off delay(1000); // wait for a second }
  • 31. Hack 01: Change the Blinking Speed ( 1. Change the blink speed Hint: edit the blink sketch to change the blink delay from 1 second to 1/4 second (note: 1 second = 1000 milliseconds). Then run the sketch again. 2. Stretch: Make a short on, longer off blink Hint: the delay times dont have to be the same.
  • 32. Your First Circuit E Jumper Wire LED Resistor
  • 33. Wire Up an LED > USB #0 #1 #2 5V BAT GND #4 #3 RST JUMPER WIRE
  • 34. A Note about Breadboards E All of the contact points in the same row are connected The rift separates the two sides
  • 35. Hack 02: An LED on Another Pin ( 1. Rewire your hack to move the LED to Trinket pin #2. 2. In the blink sketch, change the LED pin to match. Hint: You may have to change more than one line
  • 36. Hack 02: A Solution ( // Setup runs once void setup() { pinMode(2, OUTPUT); // Pin #2 is output } ! // Loop repeats forever void loop() { digitalWrite(2, HIGH); // turn the LED on delay(1000); // wait for a second digitalWrite(2, LOW); // turn the LED off delay(1000); // wait for a second }
  • 37. Hack 02: Another Way, Variable ( // Declarations int pinLED = 2; ! // Setup runs once at the beginning void setup() { pinMode(pinLED, OUTPUT); // Pin is output } ! // Loop runs over and over again forever void loop() { digitalWrite(pinLED, HIGH); // turn the LED on delay(1000); // wait for a second digitalWrite(pinLED, LOW); // turn the LED off delay(1000); // wait for a second } Declare Variable pinLED = 2
  • 38. Variable Declaration E int pinLED = 2; TYPE NAME VALUE
  • 39. Libraries Make It Easier
  • 40. Add the BobaBlox Library > 1 2 Select BobaBlox Folder from the class software download
  • 41. Load and Run the LEDBlinkPinLibrary Example >
  • 42. Whats Different About This Sketch? E // Include the library #include ! // Declarations LED boardLED(1); // Declare an LED on pin #1 ! // Setup runs once at the beginning void setup() { } ! // Loop repeats forever. Use the blink method to blink boardLED void loop() { boardLED.blink(); }
  • 43. LED Variable Declaration E LED boardLED(1); TYPE NAME PIN
  • 44. Using a Function (method) E boardLED.blink(); NAME METHOD NAME
  • 45. Another Version of the Blink Method E boardLED.blink(1, 100); # TIMES DELAY
  • 46. Hack 03: An LED on Another Pin ( 1. Change the library Blink sketch to use an LED on pin #3 Hint: You can add a 2nd LED, or move the LED you connected in the previous hack.
  • 47. Hack 04: Fast Blink ( 1. Change the library sketch to blink faster Hint: look at the example of the LED blink method that uses two parameters, times and delay.
  • 48. Hack 05: Blink Morse Code ( 1. Load and run the SOS sketch from planningness2014 examples. Note: In Morse Code, S is dot-dot-dot, O is dash-dash- dash. 2. Change the sketch so it blinks CQ. Hint: In Morse Code, C is dot-dash-dot-dash, Q is dash-dash-dot-dash. Note: CQ is a little like YO in the ham radio world.
  • 49. For the Wanderer: Examples E
  • 50. For the Wanderer: Reference E
  • 51. ?
  • 52. Chips + Circuits