Pragpub #022, April 2011
Total Page:16
File Type:pdf, Size:1020Kb
The Pragmatic Bookshelf PragPubThe First Iteration IN THIS ISSUE * Advanced Arduino Hacking * Create your Own Arduino IDE * Testing Arduino Code * Test Abstraction * When Did That Happen? The Arduino Issue In which we bring serious software development tools to the popular single-board platform. Issue #22 April 2011 PragPub • April 2011 Contents FEATURES Advanced Arduino Hacking ................................................................................ 4 by Maik Schmidt You want to get into this popular open-source electronics prototyping platform, but you don’t want to have to work with development tools designed for artists and hobbyists. Maik shows you how to develop software for Arduino in a professional way. Create your Own Arduino IDE ........................................................................ 22 by Maik Schmidt If you’re going to do serious Arduino development, you may want to work in an environment more like your day job. Here Maik shows how to set up your own IDE. Testing Arduino Code ......................................................................................... 24 by Ian Dees Ian brings the testing power of the Ruby-based Cucumber testing library to the Arduino. Test Abstraction .................................................................................................... 33 by Jeff Langr, Tim Ottinger Use the techniques in this article to sniff out problems and improve tests by increasing their level of abstraction. When Did That Happen? ................................................................................... 42 by Dan Wohlbruck Claude Shannon was born in this month in 1916. Two decades later, he made history. — i — DEPARTMENTS Up Front ..................................................................................................................... 1 by Michael Swaine Just because it’s a hobby that doesn’t mean you don’t need power tools. Choice Bits ................................................................................................................ 2 A few selected sips from the Twitter stream. The Quiz ................................................................................................................... 45 by Michael Swaine Just your basic Arduino Sudoku. Calendar ..................................................................................................................... 47 After a slow-ish winter, things are really heating up this spring. Shady Illuminations .............................................................................................. 58 by John Shade Some elements of Sun Microsystems were never going to survive the move to Oracle. John runs down the Doomed from the Get-Go list. Except where otherwise indicated, entire contents copyright © 2011 The Pragmatic Programmers. Feel free to distribute this magazine (in whole, and for free) to anyone you want. However, you may not sell this magazine or its content, nor extract and use more than a paragraph of content in some other publication without our permission. Published monthly in PDF, mobi, and epub formats by The Pragmatic Programmers, LLC, Dallas, TX, and Raleigh, NC. E-Mail [email protected], phone +1-800-699-7764. The editor is Michael Swaine ([email protected]). Visit us at http://pragprog.com for the lowdown on our books, screencasts, training, forums, and more. ISSN: 1948-3562 — ii — Up Front Bringing Serious Software Welcome to our first-ever Arduino issue! Development to the Arduino Arduino, as the whole geek-speaking world knows by now, is an extremely by Michael Swaine accessible open-source single-board microcontroller designed for pursuing electronics projects. Also as the whole geek-speaking world knows by now, Arduino is very popular. Over 100,000 boards have been sold so far, and the fascination shows no signs of abating. We’re a hard-core software developers’ magazine, so that’s the approach we’re taking to Arduino in this issue. We figure you want to get into this popular open-source electronics prototyping platform, but you don’t want to have to work with development tools designed for artists and hobbyists. So Arduino master Maik Schmidt shows you how to develop software for Arduino in a professional way. Ian Dees gets into the act, too, showing how to bring serious software testing to the Arduino. Just because it’s a hobby that doesn’t mean you don’t need power tools. Of course we also have lots of other good stuff in this packed issue. Jeff Langr and Tim Ottinger offer up a thoughtful article on Test Abstraction, Dan Wohlbruck offers another in his series on computer history, John Shade has some thoughts on Sun, Oracle, and the Doomed List, and there is a quiz (Arduino-themed, of course). Arduino Resources We recommend that you include in your Arduino toolkit Maik’s book, Arduino: A Quick-Start Guide [U1]. But there are other books to check out, including these two new ones from O’Reilly: Arduino Cookbook [U2] by Michael Margolis and Make: Arduino Bots and Gadgets [U3] by Tero Karvinen and Kimmo Karvinen. Also, here are three sites Maik tells us are must-visits for the Arduino hacker: makershed.com [U4], adafruit.com [U5], and hackaday.com [U6]. External resources referenced in this article: [U1] http://pragprog.com/refer/pragpub22/titles/msard/arduino [U2] http://oreilly.com/catalog/9780596802486/ [U3] http://oreilly.com/catalog/0636920010371/ [U4] http://makershed.com [U5] http://adafruit.com [U6] http://hackaday.com/ PragPub April 2011 1 Choice Bits Top 11 books, tweets from the coding life, and better beer through Arduino What’s Hot hacking... Top-Ten lists are passé—ours goes to 11. These are the top titles that folks are interested in currently, along with their rank from last month. This is based If you can’t do it with an Arduino, is it really worth solely on direct sales from our online store. doing? 1 NEW iOS Recipes 2 1 Agile Web Development with Rails 3 3 The RSpec Book 4 NEW Programming Concurrency on the JVM 5 5 Crafting Rails Applications 6 7 Programming Ruby 1.9 7 4 Rails Test Prescriptions 8 2 Hello, Android 9 9 Seven Languages in Seven Weeks 10 6 HTML5 and CSS3 11 NEW Pragmatic Thinking and Learning My Arduino Why would you want to buy and program an open-source, single-board microcontroller? Why, to improve your home-brewed beer, of course! • Wooh! got our #arduino powered 1950s telephone up and running! #knowledgelives — @bluec • Making a temperature logger for my fermentation with an #arduino Gonna be interesting :) #homebrew — @stoffers • Etch a Sketch clock: http://bit.ly/b5Gdfw #awesome #maker #arduino — @erinldoyle • Arduino Tic-Tac-Toe http://bit.ly/hcHs48 #arduino — @tipie • A networked candy grabber http://www.pimedius.com/Candygrabber #arduino — @dboardman • Spent a very interesting afternoon writing laser harp control software in #arduino. — @moray_macdonald • Made a bunch of optimizations on the #oracle database. Now everything is running smoothly on an #arduino. I'm very proud of myself! — @cscmeu • How to Make a Brain-controlled Device http://bit.ly/dKXL3H #arduino — @romainsauvez • HIDUINO: Your #Arduino is Now A #MIDI Interface http://bit.ly/eAlK36 — @jocequelo • Monkey Automatons! http://bit.ly/egyXH7 #arduino — @tipie PragPub April 2011 2 This Coding Life • I'm missing out. Apparently, I need to stop coding so much and spend more time on twitter arguing about how best to write code. — @benrady • I also feel that "fast-paced work environment" means "disorganized with lots of overtime." http://bit.ly/gC4JSA — @bphogan • Have to say this again: Regex section of Stackoverflow is the outstanding late Saturday night infotainment http://bit.ly/i4esC4 — @staffannoteberg • I may be the last living human who remembers using submit and supersub in CP/M. — @tottinge • @coreyhaines As context-driven testers, we've named at least three contexts in which context-driven is a bad idea. Craft demands that. — @michaelbolton • You know what keeps me grounded? The aluminum case on my MacBook Pro. #shocking — @benrady • SpacebarOnTheMacQuitWorkingTakingItToTheGeninusBar — @venkat_s Need to Know • Dogs are the new fashion exercise accessory. http://j.mp/goUwfH /via @khoi — @tswicegood • Antique clown shoes: The nouvelle vague of hipsterism twitpic.com/4bb2u7 — @noradio • Acid test: RT @Fritinancy: RT @Mxrk: Adding lime juice to any recipe is low-cal way to find out if you have any paper cuts — @makower • ProTip: calling self when you mean to call super can lead to bad, bad things happening. — @jeff_lamarche • Today was better than yesterday. Tomorrow will be better than today. And so on. #recursion #tailcalloptimization — @chadfowler • note to self: laptop as alarm clock works best when plugged into wall #savebytriplelyredundantalarms — @adamgoucher • Must be just about leave-secret-iPhone-in-a-bar time of year. (via @drewmccormack) — @dimsumthinking • nothing says "viable and sustainable business model" like building an app on top of a service owned by someone else. — @bphogan • Cegłowski's first law of Internet business: "Never get in the way of people trying to give you money" http://pinboard.in/blog/173/ — @tottinge • Why does my iPhone insist on correcting thing to thong? Amusing, but not helpful. — @duncan This month we were tuned to the tweeting channel of David Boardman, Michael Bolton, James Duncan Davidson, Erin Doyle, Chad Fowler, Adam Goucher, Corey Haines, Brian Hogan, knowledgelives, Jeff Lamarche, Moray Macdonald, Joel Makower, Marcel Molina, Staffan Nöteberg, Christophe Nowicki, Tim Ottinger, Tius