a i d e M l a n o i t a n r e t n I r o t k e l E t h g i r y p o c ernarvuino_14x21_UK.book Page iii Vendredi, 20. septembre 2013 10:12 10 Table of Contents 1. Quick Start Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 1.1 Software Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 1.2 Installing the Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 1.2.1 Windows (XP or Later) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.2.2 Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.2.3 Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a. . . . . . . . . . . 14 i d 1.3 Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 e M l a 2. Introduction . . . . . . . . . . . . . . . . . . . . . . .n . . . . . . . . . . . . . . . . . . . .17 o i t a 2.1 Someone Knocks at the Door . . . . . . n. . . . . . . . . . . . . . . . . . . . . . . . . . .17 r 2.2 Where Are We Going? . . . . . . . . .e . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18 t n I r o 3. Know Your Oppokntent. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 e l E 3.1 A Short History o f Microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 t h 3.2 They are Cuteg, but What's Inside? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 3.2.1 Threi Processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 y 3.2.2 pThe Oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.2.3 o Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 c 3.2.4 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.2.5 Input/Output Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.2.6 Analog-to-Digital Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.2.7 Digital-to-Analog Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.2.8 Communication Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.2.9 Time Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 3.2.10 Other Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.3 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29 3.3.1 Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.3.2 Loading the Program into the MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3.3.3 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 ernarvuino_14x21_UK.book Page iv Vendredi, 20. septembre 2013 10:12 10 iv 4. Rapid Prototyping Italian Style . . . . . . . . . . . . . . . . . . . . . .35 4.1 The Godfather 1, 2 and 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 4.2 Pasta, Cheese and Tomato Sauce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36 4.3 Base Ingredients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 4.4 The Kitchen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43 4.4.1 File Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45 4.4.2 Edit Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47 4.4.3 Sketch Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48 4.4.4 Tools Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49 a 4.4.5 Help Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i. . . . . . . . . .50 d 4.4.6 Manage the Tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .e . . . . . . . . . . . .51 M 4.5 The Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52 4.5.1 Table Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . .l . . . . . . . . . . . . . . . . .52 a 4.5.2 The Headwaiter . . . . . . . . . . . . . . . . . . . . . . . n. . . . . . . . . . . . . . . . . . . .53 o i t a n 5. My First Offense . . . . . . . . . . . .e .r . . . . . . . . . . . . . . . . . . . . . . . . .55 t n I 5.1 The Wrench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56 r o 5.2 Get to Know the Hood . . . .t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58 k 5.3 Preparing the Job . . . . . . .e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59 l E 5.4 A Sizeable Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60 t h 5.5 The Snitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61 g i 5.6 Flashing Lightrs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62 y p 5.7 Incarcerated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63 o c 5.8 Out on Parole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .64 5.9 Reintegration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68 6. Digital Signals: All or Nothing . . . . . . . . . . . . . . . . . . . . . . .69 6.1 Surprises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 6.2 More Surprises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72 6.3 The Matrix Keyboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73 6.4 Charlie to the Rescue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75 ernarvuino_14x21_UK.book Page v Vendredi, 20. septembre 2013 10:12 10 v 6.5 Repeat Yourself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 6.6 The Story of the Three Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79 6.6.1 for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 6.6.2 while . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 6.6.3 do-while . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 6.7 More Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83 6.8 Ghostbusters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86 6.9 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87 6.10 LED Mini-Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90 6.11 The Parade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a. . . . . . . . . .93 i d 6.12 A Little Scam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97 e 6.13 Making New Friends . . . . . . . . . . . . . . . . . . . . . . . . .M . . . . . . . . . . . . . .105 6.14 Null Does Not Equal Zero . . . . . . . . . . . . . . . . . a.l . . . . . . . . . . . . . . . . .106 n 6.15 Snow White’s Apple . . . . . . . . . . . . . . . . . .o . . . . . . . . . . . . . . . . . . . . .107 i 6.16 The Core . . . . . . . . . . . . . . . . . . . . . . . .a .t . . . . . . . . . . . . . . . . . . . . . . .108 n 6.17 A Trick . . . . . . . . . . . . . . . . . . . . . . .r . . . . . . . . . . . . . . . . . . . . . . . . . . .110 e t n I r 7. Analog Signals: Neoither Black Nor White . . . . . . . . . .113 t k e 7.1 The Digital SwitchoEvler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113 7.1.1 Type Cont version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 h 7.1.2 The Bulk of the Budget is Spent on Representation Costs . . . . . . . . . 117 g 7.1.3 A Tiip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 r 7.1.4 AyDC References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 p 7.2 Back oto Analog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120 c 7.3 Look Ma, No Hands! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122 7.3.1 Motor Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 7.3.2 Obtaining a Step Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 7.3.3 The Compound if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 7.3.4 The PID Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 7.3.5 The Digital Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 7.3.6 Dynamic Duo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 7.3.7 Nerd Corner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 7.3.8 Sneak Preview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 7.4 Recreation: the Misophone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142 7.5 A Bit of C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147 ernarvuino_14x21_UK.book Page vi Vendredi, 20. septembre 2013 10:12 10 vi 7.6 The No in Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149 7.7 Look Ma, No Arduino! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150 8. Communication: an Art and a Science. . . . . . . . . . . . .155 8.1 Visualize Your Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157 8.1.1 Connect a Liquid Crystal Display . . . . . . . . . . . . . . . . . . . . . . . . . . . .158 8.2 The Act of Communicating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160 8.2.1 Asynchronous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a. . . . . . .160 8.2.2 Synchronous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .d i. . . . . . . . .162 e 8.3 RS-232 or Serial Port? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 M 8.3.1 A Few Subtleties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164 l 8.3.2 Chaining Characters . . . . . . . . . . . . . . . . . . . . . a. . . . . . . . . . . . . . . . .166 n 8.3.3 Breaking the Chains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171 o 8.3.4 An NMEA 0183A Decoder . . . . . . . . . . .i . . . . . . . . . . . . . . . . . . . . . .173 t 8.3.5 Mutatis Mutandis . . . . . . . . . . . . . . . . . a. . . . . . . . . . . . . . . . . . . . . . . .176 n 8.3.6 Make a U-turn Now . . . . . . . . . . . .r . . . . . . . . . . . . . . . . . . . . . . . . . . .178 e 8.3.7 A Curly Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .185 t n 8.4 Two-Wire Connections . . . . . . . .I . . . . . . . . . . . . . . . . . . . . . . . . . . . . .185 8.4.1 I²C, TWI and Arduino . o. .r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .186 8.4.2 Atmospheric Pressure tSensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188 k e 8.5 Three- and Four-Wire Connections . . . . . . . . . . . . . . . . . . . . . . . . . . .195 l E 8.5.1 Improved Driver for Graphic Display . . . . . . . . . . . . . . . . . . . . . . . . .196 8.5.2 Humidity Shetnsor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .200 g 8.6 All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .207 i r y 8.7 When Arduino Isn’t Around . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211 p o 8.8 Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .212 c 8.9 Did you Know? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 9. Clock is Ticking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219 9.1 This is Radio Frankfurt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219 9.1.1 DCF77 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .220 9.2 Daisy-Chaining Seconds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .223 9.3 Decode a String of Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227 9.3.1 DCF77 Decoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .228 ernarvuino_14x21_UK.book Page vii Vendredi, 20. septembre 2013 10:12 10 vii 9.4 Millis and Micros, Two Little Functions . . . . . . . . . . . . . . . . . . . . . . . .232 9.5 PWM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .233 9.5.1 Two Types of PWM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 9.6 The Master of Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .234 9.6.1 DCF77 Transmitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 9.7 Could do Better . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244 9.8 Expecting a Happy Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246 9.8.1 Sort Your Infrared Remote Controls . . . . . . . . . . . . . . . . . . . . . . . . . . 248 9.9 Break or Continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252 9.10 Divide and Conquer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a. . . . . . . . .252 i d 9.11 The Structured Union of Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .253 e 9.11.1 struct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M. . . . . . . . . . . . . . . . 253 9.11.2 union . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 l 9.11.3 typedef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . a. . . . . . . . . . . . . . . . . . . . 254 n 9.12 Is It an Image? Is It data? It’s Superfile! . . .o . . . . . . . . . . . . . . . . . . . . .255 i 9.12.1 The SVG File Format . . . . . . . . . . a. t. . . . . . . . . . . . . . . . . . . . . . . . . . 256 n 9.13 What They Really Say . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .260 r e 9.13.1 The NEC-1 Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 t n 9.14 To goto Or Not to goto . . . . .I . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266 r 9.15 Frame It Yourself . . . . . . o. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268 t 9.15.1 Composition . . .k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 e 9.15.2 Exposure Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 l E 9.15.3 Capturing Volatile Moments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 t 9.16 Occupation: Riohter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .274 g 9.17 Summarizirnig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280 y 9.17.1 pNormal Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 9.17.2o CTC Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 c 9.17.3 Capture Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 9.18 May The Force Be With You . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281 10. Interrupts - Pandora’s Box . . . . . . . . . . . . . . . . . . . . . . . . . .283 10.1 My First Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .284 10.1.1 Timer/Counter 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 10.1.2 Generating a 1 kHz Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 10.2 The Devil in Disguise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .287 10.2.1 What’s Our Vector, Victor? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 ernarvuino_14x21_UK.book Page viii Vendredi, 20. septembre 2013 10:12 10 viii 10.3 Message in a Bottle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .292 10.4 Spinning Out Of Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .293 10.5 Knock on Any Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .296 10.5.1 Let’s Make a Flip-Flop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .296 10.6 One Interrupt Too Many . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .298 10.6.1 The Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .299 10.7 Who's That Knocking At My Door? . . . . . . . . . . . . . . . . . . . . . . . . . . .300 10.7.1 Multiplexed Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .301 10.8 Long Live the Rotary Encoder! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .303 10.9 Reset In Every Possible Way . . . . . . . . . . . . . . . . . . . . . . . . . . a. . . . . .309 i 10.9.1 POR, BOR and BOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . .d . . . . . . . . .310 e 10.10 Let’s Switch Roles . . . . . . . . . . . . . . . . . . . . . . . . . . . . .M . . . . . . . . . . .311 10.10.1 The Annoiser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311 l a 10.11 La Cucaracha . . . . . . . . . . . . . . . . . . . . . . . . . . . . .n . . . . . . . . . . . . . . . .314 10.11.1 The 1-Wire Protocol . . . . . . . . . . . . . . . . . .o . . . . . . . . . . . . . . . . . . . .317 i t 10.12 Fire! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .a . . . . . . . . . . . . . . . . . . . . .322 n 10.12.1 The SMBus . . . . . . . . . . . . . . . . . .r . . . . . . . . . . . . . . . . . . . . . . . . . . .323 e t n I r o Programs Overview . . . . . . . . . .t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329 k e Illustrations Overview . . . E. l. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .330 t h Tables Overview . . . g. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .336 i r y Index. . . . . . . . . .p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337 o c ernarvuino_14x21_UK.book Page 35 Vendredi, 20. septembre 2013 10:12 10 4. Rapid Prototyping Italian Style Arduino, from Italy, is a rapid prototyping platform for microcontroller applica- tions. This means that it is a set of tools developed to facilitate the design of micro- controller-based circuits without wasting too much time on learning the ins and outs of the platform. With Arduino, you too can do “microcontrollers” and “embedded electronics”. Now I’m gonna make you an offer you can’t refuse: get yourself one of those cheap Arduino boards, install the free software tools, keep your evenings free and I will teach you how to use it all. a i d e M 4.1 The Godfather 1, 2 and 3 l a n Arduino is related to the open-source techno-popoularizing projects Processing i t from which it borrowed the programming enviraonment and Wiring that provided n the foundations of the code libraries. r e Processing “is an open source programmnting language and environment for people who want to create images, animati oIns, and interactions. Initially developed to r serve as a software sketchbook anod to teach fundamentals of computer program- t ming within a visual context, Prkocessing also has evolved into a tool for generat- e ing finished professional wolrk.” (source: www.processing.org) E Wiring, Italian like Ardtuino, is a programming framework for microcontrollers h “created with designgers and artists in mind to encourage a community where i beginners throughr experts from around the world share ideas, knowledge and y their collectivep experience.” (source: www.wiring.org.co) o c Arduino (www.arduino.cc) was conceived at the same school as Wiring and is a simplification of the latter, which in itself was already quite easy to use. Originally Wiring was not open-source, but under the pressure from the Arduino team, Wir- ing gave in and published its source code. Then the Arduino team could get going. The goal of Arduino is to make microcontrollers accessible to students, non-spe- cialists, artists, designers, enthusiasts and all those who are interested in the cre- ation of interactive objects and environments, but who do not have (well- developed) electronics and/or programming skills and who do not always have a lot of money. Therefore the Arduino team decided that their board should not cost more than $30 (€25), which was indeed the price of the first board. Since then prices have gone up marginally to reach about $35 (€30) in 2013. 35 ernarvuino_14x21_UK.book Page 36 Vendredi, 20. septembre 2013 10:12 10 4. Rapid Prototyping Italian Style The first Arduino boards were more basic than the Wiring boards, but over time the Arduino hardware became more elaborated, whereas Wiring extended its range by simplifying their boards. Now (in 2013), Wiring S and Arduino Uno boards are very similar. Despite the equivalence of the two projects, Wiring did not meet with the same success as Arduino. From the early beginning the Arduino team has done every- thing to spread their word by publishing all source code, circuit diagrams, printed circuit board designs and detailed documentation for free, whereas the Wiring team tried to control everything. In the Fall of 2012 over 600,000 Arduino boards had been sold worldwide. a Arduino libraries are based on those from Wiring and the Integratedd Dievelopment Environment (IDE), based on the one from Processing, is almoste identical to the M Wiring IDE. The only striking difference is its color: orange for Wiring and light blue for Arduino. Processing uses shades of grey for its IDEa lwith looks very famil- iar to the two others. Other projects have started to use thne Processing IDE as well o and we can almost speak of an emerging standard. i t a The Wiring IDE supports Arduino hardware, but nthe Arduino IDE does not know r about Wiring hardware. Initially Arduino limieted itself to a few microcontrollers t from Atmel’s 8-bit AVR family while Wirinng openly flirted with microcontrollers I from for instance Microchip and Texas rI nstruments and also with MCUs based on o an ARM core. Arduino too has beent transformed into a multi-MCU platform, but k a little “unbeknownst to its owne free will”. The Arduino philosophy has been embraced by many enthusiastEsl who have ported it to different MCU platforms from various manufacturerts . It took a few years to modify the Arduino IDE to h allow it to include compgilers for other microcontrollers as well, but with version 1.5 and the introductiorin of the Arduino Due that sports an ARM Cortex-M3 based y MCU, this goal haps been reached. o c 4.2 Pasta, Cheese and Tomato Sauce The Arduino platform is built on three pillars: 1. The hardware consisting of a collection of microcontroller and expansion boards. Circuit diagrams and printed circuit board designs are available for free; 2. Software comprising of programming tools and an extensive library of high- level functions. Everything is free, open-source and multi-platform; 36 ernarvuino_14x21_UK.book Page 37 Vendredi, 20. septembre 2013 10:12 10 4.2 Pasta, Cheese and Tomato Sauce 3. Distribution and communication in the shape of a website through which the Arduino hardware and software are made available to interested parties. The address is www.arduino.cc (arduino.cc also works). For the curious, .cc is the internet country code top-level domain reserved for the National Territory of Cocos (formerly Keeling) Islands, an Australian territory. This top-level domain was probably chosen for its low cost, but I digress. The website is the official reference for everything that concerns Arduino. The website contains software and hardware updates and all the information necessary to use it all. If you are looking for a reseller of authentic Arduino hardware, it is here that you can find one. A forum to ask questions that are not answered in this a book is also available. The site is in English, but there are sub-fdoirums accommo- dating other languages too. e M l a n o i t a n r e t n I r o t k e l E Leonardot Lilypad h g i r y p o c Mega ADK Chinese Uno Figure4-1- Some less common Arduino boards: the Leonardo (without connectors) is equipped with an ATmega32U4 and targets USB devices; the daisy-shaped Lilypad aimed at wearable applications; the Mega ADK for communication with Android devices and a Chinese Uno clone recognizable from the missing “Made in Italy” statement. 37
Description: