Vous êtes sur la page 1sur 35

Introduction to Arduino

!! Picture Hardware Hacking

by nicholasjon- flickr

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

What is hardware hacking


!! Hacking
"! An elegant solution to a difficult problem "! Using a technology for something it was not originally intended.

Types of hardware hacking


!! Just hacking hardware !! Circuit Bending !! Reverse Engineering !! Toy Hacking !! SteamPunk !! Craft Hacking/Making

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

*Well come to this shortly

Arduino (Atmega 328)


!! 16bit Microprocessor, Embedded C !! 32k Flash, 2k SRAM, 1k EEPROM !! 16Mhz

Arduinos are not the only fruit


!! Atmel Tiny (ATtiny) !! PIC AVR (PICAXE) !! Range of ARM processors !! FPGA

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

Arduino Initiatives
!! Software
"! Processing
!! IDE is based on Processing and Wiring

"! Fritzing
!! Prototyping and circuit layout

!! EduWear
"! Introducing programming and electronics to children

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/

Board Roadmap
!! Powering the Board !! Digital I/O incl. PWM !! Analog I/O !! Communicating with the board

Anatomy of a Sketch
!! How we tell the Arduino what to do!
!! Getting a sketch to the board

!! C program!
"! Two functions setup/run "! Api : http://arduino.cc/en/Reference/HomePage

First Sketch!
!! Open _1_Blink !! Key Points
"! "! "! "! setup, loop pinMode digitalWrite delay

Lets Hack It
!! Change the Frequency? !! Faster than the Eye can see? (>24 Hz) !! Change the Duty Cycle?

Breadboard it up!
!! Move the circuit to the Breadboard

Lets Hack It

We Created PWM
!! Pulse Width Modulation

"! Built Into the Arduino "! Open _2_PWM to see it in action

!! Key points
!! analogWrite

Lets Hack It
!! Change the speed of the dimming cycle? !! Only dim half way?

Whats PWM For?


!! Servos !! Motors !! Displays !! Power Supplies !! Audio !! Heater Control !! Analog Aproximation

Where is the Input?


!! Add a simple button input! !! Pull up/down (some elec theory)

Breadboard View

Reading the Input


!! Open _3_Button !! Key Points
"! If Statement "! digitalRead

Lets Hack It
!! Change it to toggle? !! Do we see any problems?

Better Buttons
!! Open _4_Debounce !! Key Points
"! Global "! Millis()

Extend it!
!! Setup 3 Leds (pins 11,10,9)
"! Current limiting resistors?

!! Setup button on pin 2 !! Open _5_Reflex


"! No Debounce? "! Complicated Control Logic? "! While Loop

Build

Build

Lets Hack It
!! Find your fastest time? !! Make lights go in reverse order? !! Can you make them sweep instead of loop? !! What other cool changes can you make?

The Real Game

The Real Game

An Analog Sensor
!! Open _6_Temp !! Elec Stuff
"! Thermistor "! Voltage Drop

!! Key Points
"! analogRead "! No setup!

Build

Build

Free Hack
!! Can you combine the temp and reflex game code to make a readout for the temp? !! Break the range of values up and assign a range to each led. !! Talk to each other, ask questions, if you need a hint look at _7_Solution after giving it a good try.

Vous aimerez peut-être aussi