cover.eps

Arduino For Dummies®

Visit www.dummies.com/cheatsheet/arduino to view this book's cheat sheet.

Table of Contents

Introduction

About This Book

Foolish Assumptions

How This Book Is Organized

Part I: Getting to Know Arduino

Part II: Getting Physical with Arduino

Part III: Building on the Basics

Part IV: Unlocking Your Arduino’s Potential

Part V: Sussing Out Software

Part VI: The Part of Tens

Icons Used in This Book

Where to Go from Here

Part I: Getting to Know Arduino

Chapter 1: What Is Arduino and Where Did It Come From?

Where Did Arduino Come From?

Learning by Doing

Patching

Hacking

Circuit bending

Electronics

Inputs

Outputs

Open Source

Chapter 2: Finding Your Board and Your Way Around It

Getting to Know the Arduino Uno R3

The Brains: ATmega328 microcontroller chip

Header sockets

Digital pins

Analog in pins

What about analog out?

Power pins

USB socket

External power jack

Reset button

Discovering Other Arduino Boards

Official Arduino boards

Contributed (Approved) Arduinos

Shopping for Arduino

Official Arduino Store

Distributors in the United Kingdom

Distributors in the United States

Amazon

Electronics distributors

Kitted Out: Starting with a Beginner’s Kit

Preparing a Workspace

Chapter 3: Downloading and Installing Arduino

Installing Arduino

Installing Arduino for Windows

Installing Arduino for Mac OS X

Installing Arduino for Linux

Surveying the Arduino Environment

Chapter 4: Blinking an LED

Working with Your First Arduino Sketch

Finding the Blink Sketch

Identifying your board

Configuring the software

Uploading the sketch

Congratulate yourself!

What just happened?

Looking Closer at the Sketch

Comments

Declarations

Variables

Functions

Setup

Loop

Blinking Brighter

Tweaking the Sketch

Part II: Getting Physical with Arduino

Chapter 5: Tools of the Trade

Finding the Right Tools for the Job

Breadboard

Jump wires

Needle-nose pliers

Multimeter

Using the Multimeter to Measure Voltage, Current, and Resistance

Measuring voltage (in volts) in a circuit

Measuring current (in amps) in a circuit

Measuring resistance (in ohms) of a resistor

Measuring resistance (in ohms) of a variable resistor

Checking the continuity (in bleeps) of your circuit

Chapter 6: A Primer on Electricity and Circuitry

Understanding Electricity

Using Equations to Build Your Circuits

Ohm’s Law

Calculating power

Joule’s Law

Working with Circuit Diagrams

A simple circuit diagram

Using a circuit diagram with an Arduino

Color Coding

Datasheets

Resistor Color Charts

Chapter 7: Basic Sketches: Inputs, Outputs, and Communication

Uploading a Sketch

Using Pulse Width Modulation (PWM)

The LED Fade Sketch

Understanding the fade sketch

Tweaking the fade sketch

The Button Sketch

Understanding the Button sketch

Tweaking the Button sketch

The AnalogInput Sketch

Understanding the AnalogInput sketch

Tweaking the AnalogInput sketch

Talking Serial

The DigitalReadSerial Sketch

Understanding the DigitalReadSerial sketch

The AnalogInOutSerial Sketch

Understanding the AnalogInOutSerial sketch

Chapter 8: More Basic Sketches: Motion and Sound

Working with Electric Motors

Discovering Diodes

Spinning a DC Motor

The Motor sketch

Understanding the Motor sketch

Changing the Speed of Your Motor

The MotorSpeed sketch

Understanding the MotorSpeed sketch

Controlling the Speed of Your Motor

The MotorControl sketch

Understanding the MotorControl Sketch

Tweaking the MotorControl sketch

Getting to Know Servo Motors

Creating Sweeping Movements

The Sweep sketch

Understanding the Sweep sketch

Controlling Your Servo

The Knob sketch

Understanding the Knob sketch

Making Noises

Piezo buzzer

The toneMelody sketch

Understanding the sketch

Making an Instrument

The PitchFollower sketch

Understanding the sketch

Part III: Building on the Basics

Chapter 9: Learning by Example

Skube

How it works

Further reading

Chorus

How it works

Further reading

Push Snowboarding

How it works

Further reading

Baker Tweet

How it works

Further reading

The National Maritime Museum’s Compass Lounge and Compass Card

How it works

Further reading

The Good Night Lamp

How it works

Further reading

Little Printer

How it works

Further reading

Flap to Freedom

How it works

Further reading

Chapter 10: Soldering On

Understanding Soldering

Gathering What You Need for Soldering

Creating a workspace

Choosing a soldering iron

Solder

Third hand (helping hand)

Adhesive putty

Wire cutters

Wire strippers

Needle-nosed pliers

Multimeter

Solder sucker

Solder wick

Equipment wire

Staying Safe while Soldering

Handling your soldering iron

Keeping your eyes protected

Working in a ventilated environment

Cleaning your iron

Don’t eat the solder!

Assembling a Shield

Laying out all the pieces of the circuit

Assembly

Header pins

Acquiring Your Soldering Technique

Building Your Circuit

Knowing your circuit

Laying out your circuit

Preparing your wire

Soldering your circuit

Cleaning up

Testing your shield

Packaging Your Project

Enclosures

Wiring

Securing the board and other elements

Chapter 11: Getting Clever with Code

Blinking Better

Setting up the BlinkWithoutDelay sketch

Understanding the BlinkWithoutDelay sketch

Taking the Bounce Out of Your Button

Setting up the Debounce sketch

Understanding the Debounce sketch

Making a Better Button

Setting up the StateChangeDetection sketch

Understanding the StateChangeDetection sketch

Smoothing Your Sensors

Setting up the Smoothing sketch

Understanding the Smoothing sketch

Calibrating Your Inputs

Setting up the Calibration sketch

Understanding the Calibration sketch

Chapter 12: Common Sense with Common Sensors

Making Buttons Easier

Implementing the DigitalInputPullup sketch

Understanding the DigitalInputPullup sketch

Exploring Piezo Sensors

Implementing the Knock sketch

Understanding the Knock sketch

Utilizing Pressure, Force, and Load Sensors

Implementing the toneKeyboard sketch

Understanding the toneKeyboard sketch

Sensing with Style

Implementing the CapPinSketch sketch

Understanding the CapPinSketch sketch

Tripping Along with Lasers

Implementing the AnalogInOutSerial sketch

Understanding the AnalogInOutSerial sketch

Detecting Movement

Implementing the DigitalReadSerial sketch

Understanding the DigitalReadSerial sketch

Measuring Distance

Implementing the MaxSonar sketch

Understanding the MaxSonar sketch

Testing, Testing . . . Can Anybody Hear This?

Implementing the AnalogInOutSerial sketch

Understanding the AnalogInOutSerial sketch

Part IV: Unlocking Your Arduino’s Potential

Chapter 13: Becoming a Specialist with Shields and Libraries

Looking at Shields

Considering combinations

Reviewing the field

Staying current

Browsing the Libraries

Reviewing the standard libraries

Installing additional libraries

Obtaining contributed libraries

Chapter 14: Sensing More Inputs and Controlling More Outputs

Controlling Multiple LEDs

Implementing the AnalogWriteMega sketch

Understanding the AnalogWriteMega Sketch

Tweaking the AnalogWriteMega sketch

Controlling Lots of LEDs by Shifting Out

Implementing the shiftOutCode, Hello World sketch

Understanding the shiftOutCode, Hello World sketch

Tweaking the shiftOutCode, Hello World sketch

Doing more with the same circuit

Chapter 15: Multiplying Your Outputs with I2C

What Is I2C?

Assembling the I2C PWM/Servo Driver

Using the I2C PWM/Servo Driver

Understanding the I2C PWM/Servo Driver Sketch

Buying Servo Motors

Other Uses for I2C

Part V: Sussing Out Software

Chapter 16: Getting to Know Processing

Looking Under the Hood

Installing Processing

Taking a look at Processing

Trying Your First Processing Sketch

Drawing shapes

Changing color and opacity

Playing with interaction

Chapter 17: Processing the Physical World

Making a Virtual Button

Setting up the Arduino code

Setting up the Processing code

Understanding the Processing PhysicalPixel sketch

Understanding the Arduino Physical Pixel sketch

Drawing a Graph

Setting up the Arduino code

Setting up the Processing code

Understanding the Arduino Graph sketch

Understanding the Processing Graph sketch

Sending Multiple Signals

Setting up the Arduino code

Setting up the Processing code

Understanding the Arduino SerialCallResponse sketch

Understanding the Processing SerialCallResponse sketch

Part VI: The Part of Tens

Chapter 18: Ten Places to Learn More about Arduino

Arduino Blog

Hack a Day

SparkFun

MAKE

Adafruit

Bildr

Instructables

YouTube

Hackerspaces

Forum

Friends, Colleagues, and Workshops

Chapter 19: Ten Great Shops to Know

Shops in the United Kingdom

SK Pang

Technobots

Proto-PIC

Oomlout

RoboSavvy

Active Robots

Shops around the World

Adafruit (U.S.)

Arduino Store (Italy)

Seeed Studio (China)

SparkFun (U.S.)

Chapter 20: Ten Places to Find Parts and Components

RS Components (World)

Farnell (World)

Rapid (World)

Digi-Key (World)

eBay (World)

Maplin (U.K.)

RadioShack (U.S.)

Ultraleds (U.K.)

EnvironmentalLights.com (U.S.)

Skip/Dumpster Diving (World)

Cheat Sheet

About the Author

John Nussey is a creative technologist based in London. His work involves using technology in new and interesting ways and covers many areas, including physical computing, creative coding, interaction design, and product prototyping.

During his career, he has worked on many varied projects with clients such as ARUP, the BBC, the Museum of Science and Industry, the National Maritime Museum, Nokia, and the Southbank Centre.

He is a proud advocate of the Arduino prototyping platform and has taught the craft of interaction design and prototyping to people of all ages, competencies, and abilities at a variety of establishments, including Goldsmiths College, the Bartlett School of Architecture, the Royal College of Art, and OneDotZero.

Dedication

To Avril, the love of my life (and only person I trust with a soldering iron), for providing encouragement when I was writing and distraction when I wished I wasn’t; to Roanne and Oliver for our stimulating literary chats; to Craig for helping me bridge the trans-Atlantic gap; to all the guys and girls at Kin for still feigning interest and asking “How’s the books going?” after 6 months; and to Alexandra for all the guidance that led me to such an enjoyable and inspiring career.

Author’s Acknowledgments

John would like to thank the folks at Wiley, especially Craig Smith for always being upbeat and his gentle reminders, and Susan Christophersen for her hard work and support throughout.

Many thanks to Andy Huntington for his excellent technical editing and occasional humorous comments that helped me through the long nights.

A big thanks to all my friends, family, and loved ones for their encouragement and enthusiasm. I love making things, and I hope that this book inspires you to make things of your own and find the same enjoyment I have.

Publisher’s Acknowledgments

We’re proud of this book; please send us your comments at http://dummies.custhelp.com. For other comments, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.

Some of the people who helped bring this book to market include the following:

Acquisitions, Editorial

Project and Copy Editor: Susan Christophersen

Executive Commissioning Editor: Craig Smith

Development Editors: Susan Christophersen, Susannah Gardner

Technical Editor: Andy Huntington

Editorial Manager: Jodi Jensen

Senior Project Editor: Sara Shlaer

Editorial Assistant: Leslie Saxman

Cover Photo: © John Nussey

Cartoons: Rich Tennant (www.the5thwave.com)

Marketing

Associate Marketing Director: Louise Breinholt

Marketing Manager: Lorna Mein

Senior Marketing Executive: Kate Parrett

Composition Services

Senior Project Coordinator: Kristie Rees

Layout and Graphics: Carrie A. Cesavice, Melanee Habig, Joyce Haughey, Andrea Hornberger, Christin Swinford

Proofreader: Wordsmith Editorial

Indexer: Potomac Indexing, LLC

UK Tech Publishing

Michelle Leete, VP Consumer and Technology Publishing Director

Martin Tribe, Associate Director–Book Content Management

Chris Webb, Associate Publisher

Publishing and Editorial for Technology Dummies

Richard Swadley, Vice President and Executive Group Publisher

Andy Cummings, Vice President and Publisher

Mary Bednarek, Executive Acquisitions Director

Mary C. Corder, Editorial Director

Publishing for Consumer Dummies

Kathleen Nebenhaus, Vice President and Executive Publisher

Composition Services

Debbie Stailey, Director of Composition Services

Foreword

The moment a For Dummies book comes out, it’s definitely a milestone in the history of a product.

Programming embedded computers used to be a very difficult task, reserved only to experienced engineers willing to master the obscure assembly language. In recent years, however, many platforms have tried to make this task simpler and more accessible to everyday people. Arduino is one of the latest attempts at making technology less scary and more creative.

With John, this book’s author, we watched this creative tool being adopted by designers and artists in London, making its way into many memorable projects. Now Arduino has escaped the lab of Arts & Design and spread like a virus, becoming the tool of choice for all kinds of people who have great ideas they want to realize.

I’m really glad that John decided to write this book, because he’s an early user of the Arduino platform from back in the days when it was still quite experimental. Having taught Arduino classes for many years, he has the ability to introduce the subject to all audiences.

Any newcomer to Arduino will, with the right tools and teaching — such as those found in this book — show true genius in no time.

Massimo Banzi

Introduction

Arduino is a tool, a community, and a way of thinking that is affecting how we use and understand technology. It has rekindled a love and understanding for electronics for many people, including myself, who felt that electronics was something that they had left behind at school.

Arduino is tiny circuit board that has huge potential. It can be used to blink a Morse-code signal using a single LED or to control every light in a building, depending on how far you take it. Its capabilities are limited only by your imagination.

Arduino is also providing a new, practical approach to technical education, lowering the entry level for those wanting to use electronics to complete small projects and, I hope, encouraging you to read further to take on big ones.

A huge and ever-growing community of Arduin-ists has emerged — users and developers who learn from each other and contribute to the open source philosophy by sharing the details of their projects. Arduin-ists and their supporters with their open source attitude are responsible for the huge popularity of Arduino.

Arduino is more than just a “bit of kit”; it’s a tool. A piece of technology that makes understanding and using today’s technology easier.

So if the prospect of understanding the limitless possibilities of technology doesn’t sound interesting to you, please put this book down and back away.

Otherwise, read on!

About This Book

This is a technical book, but it’s not for technical people only. Arduino is designed to be usable by anyone, whether they’re technical, creative, crafty, or just curious. All you need is an open mind or a problem to fix and you’ll soon find ways that using Arduino can benefit you.

Arduino has rekindled my love of electronics and opened many avenues for my career. I wrote this book to share that experience. When I first went to an Arduino workshop, I had no experience in programming and could only vaguely remember which end of a soldering iron to hold (don’t worry, I cover soldering, too). Now the mainstay of my work involves building interactive installations, prototyping products, and generally finding new ways to play with technology using Arduino.

I think it is an excellent platform that lowers the entry level into electronics and coding, allowing people who may not have had the attention span or interest at school to dive straight into the areas that interest them and explore them from there.

Foolish Assumptions

This book assumes nothing about your technical knowledge. Arduino is an easy-to-use platform for learning about electronics and programming. It is for people from all walks of life, whether you’re a designer, an artist, or a hobbyist.

It can also be a great platform for people who are already technical. Maybe you’ve done a bit of coding but want to bring your projects into the physical world in some way, or maybe you’ve worked with electronics and want to see what Arduino can bring to the table.

But whoever you are, you’ll find that Arduino has great potential. It’s really up to you to decide what to make of it.

This book starts on the most basic level to get you started with using and understanding Arduino. At times throughout the book, I may refer to a number of very technical things that will, like anything, take time to understand. I guide you through all the basics and then on to more advanced activities.

Much of what is in this book is based on my learning and teaching experiences. I learned all about Arduino from scratch, but have always found that the best way to learn is in practice, by making your own projects. The key is to learn the basics that I cover in this book and then build on that knowledge by thinking about how you can apply it to solve problems, create things, or just entertain yourself.

How This Book Is Organized

Arduino For Dummies is organized in a way that allows you to jump around the book as you like. If you’ve dabbled in Arduino before, you might want to skip to the later chapters, or if you’ve forgotten some of the basics, consider starting at the beginning.

Part I: Getting to Know Arduino

In Part I, I introduce you to Arduino, outlining a variety of other practices and circumstances that created a need for Arduino and that have influenced its development. Then I look at Arduino in more detail, both as a physical board and software environment, and I walk you through uploading your first sketch.

Part II: Getting Physical with Arduino

In this part, you find out how to do some basic prototyping using breadboards and other components to give your Arduino more reach into the physical world. Using just a few simple components, you can explore a variety of applications for Arduino and form a base on which you can build your own projects. The chapters in this part cover a variety of inputs and outputs, including light, motion, and sound that you can build on and combine to form your own projects.

Part III: Building on the Basics

After you have covered the basics, you’ll be itching to do more. In Part III, I tell you about some real-world projects and how they work. You find out how to solder your own circuit board to get your project out into the world for others to see. You also learn how to choose the correct sensor for the job and how to use code to fine-tune or change the behavior of your circuits.

Part IV: Unlocking Your Arduino’s Potential

This part pushes the possibilities of your Arduino project further. You learn about using shields to add specific functionality to your Arduino, using hardware and techniques to allow you project to grow, and hacking existing hardware. You also find out how to communicate with Processing, Arduino’s sister project, to combine open source hardware with software.

Part V: Sussing Out Software

If you work through the book to this part, you should have a good understanding of how you can use electronics and hardware in your own projects. In this part, you learn how to combine this knowledge of the physical world with the digital world of software. I introduce you to a few open source programming environments and then more specifically to Processing, which is a digital sketchbook that you can use for a huge variety of applications to enhance your Arduino project.

Part VI: The Part of Tens

The Part of Tens is a For Dummies standard that breaks down useful information into groups of ten bite-sized chunks. This part covers where to learn more about Arduino, where to shop for Arduino-specific parts, and where to shop for electronics in general.

Icons Used in This Book

Arduino For Dummies uses icons to highlight important points for you. Keep an eye out for these:

tip.eps This icon highlights a bit of helpful information. That info may be a technique to help you complete a project more easily or the answer to common problems.

warning_bomb.eps Arduinos aren’t dangerous on their own; indeed, they’re made to be extremely safe and easy to use. But if they are used in a circuit without proper planning as well as care and attention, they can damage your circuit, your computer, and yourself. When you see a Warning icon, please take special note.

remember.eps There are often points that must be considered before proceeding with a task. I use Remember icons to remind you of such points.

technicalstuff.eps Some information is more technical than others and is not for the faint hearted. The joy of Arduino is that you don’t need to fully understand the technical details immediately. You can skip anything that’s marked with this icon if it’s more complicated than you want to deal with at the moment; you can always return to it when you’re ready.

Where to Go from Here

If you’re uncertain about where to start, I suggest the beginning. By the end of Chapter 2, you’ll have acquired a simple understanding of Arduino and will know where you can get a kit to continue learning.

If you’ve used Arduino before, you may want to jump straight to Chapter 4 to cover the basics again, or head straight to the area that interests you.

Part I

Getting to Know Arduino

9781118446379-pp0101.eps

In this part . . .

So what is an Arduino, anyway? In the chapters ahead, you find out all about this little blue circuit board, how it came into being, and what it can be used for. After a brief introduction, I talk you through all the things you need to get started with Arduino and where to get them. Next, you learn how to wield the awesome power of an LED, blinking it on command with a few simple lines of code.

Chapter 1

What Is Arduino and Where Did It Come From?

In This Chapter

arrow Discovering Arduino

arrow Learning where Arduino came from and why it’s so important

arrow Introducing the basic principles

Arduino is made up of both hardware and software.

The Arduino board is a printed circuit board (PCB) that is specifically designed to use a microcontroller chip as well as other input and outputs. It also has many other electronic components that are needed for the microcontroller to function or to extend its capabilities.

Microcontrollers are small computers contained within a single, integrated circuit or computer chip, and they are an excellent way to program and control electronics. Many devices, referred to as microcontroller boards, have a microcontroller chip and other useful connectors and components that allow a user to attach inputs and outputs. Some examples of devices with microcontroller boards are the Wiring board, the PIC, and the Basic Stamp.

You write code in the Arduino software to tell the microcontroller what to do. For example, by writing a line of code, you can tell an LED to blink on and off. If you connect a pushbutton and add another line of code, you can tell the LED to turn on only when the button is pressed. Next, you may want to tell the LED to blink only when the pushbutton is held down. In this way, you can quickly build a behavior for a system that would be difficult to achieve without a microcontroller.

Similarly to a conventional computer, an Arduino can perform a multitude of functions, but it’s not much use on its own. It requires other inputs or outputs to make it useful. These inputs and outputs allow a computer to sense objects in the world and to affect the world.

Before you move forward, it might help you to understand a bit of the history of Arduino.

Where Did Arduino Come From?

Arduino started its life in Italy, at Interaction Design Institute Ivera (IDII), a graduate school for interaction design. This is a specific school of design education that focuses on how people interact with digital products, systems, and environments and how they in turn influence us.

The term interaction design was coined by Bill Verplank and Bill Moggridge in the mid-1980s. The sketch in Figure 1-1 by Verplank illustrates the basic premise of interaction design. This diagram is an excellent illustration of how the process of interaction works: If you do something, you feel a change, and from that you can know something about the world.

Although it is a general principle, interaction design more commonly refers to how we interact with conventional computers by using peripherals, such as mice, keyboards, and touchscreens, to navigate a digital environment that is graphically displayed on a screen.

9781118446379-fg0101.eps

Courtesy of Bill Verplank

Figure 1-1: The principle of interaction design, illustrated by Bill Verplank.

There is another avenue, referred to as physical computing, which is about extending the range of these computer programs, software, or systems. Through electronics, computers can sense more about the world and have a physical impact on the world themselves.

Both of these areas — interaction design and physical computing — require prototypes to fully understand and explore the interactions, which presented a hurdle for nontechnical design students.

In 2001, a project called Processing that was started by Casey Reas and Benjamin Fry aimed to get nonprogrammers into programming by making it quick and easy to produce onscreen visualizations and graphics. The project gave the user a digital sketchbook on which to try ideas and experiment with a very small investment of time. This project in turn inspired a similar project for experimenting in the physical world.

Building on the same principles as Processing, in 2003 Hernando Barragán started developing a microcontroller board called Wiring. This board was the predecessor to Arduino.

In common with the Processing project, the Wiring project also aimed to involve artists, designers, and other nontechnical people, but Wiring was designed to get people into electronics rather than programming. The Wiring board (shown in Figure 1-2) was less expensive than some other microcontrollers, such as the PIC and the Basic Stamp, but it was still a sizable investment for students to make.

9781118446379-fg0102.tif

Figure 1-2: An early Wiring board.

In 2005, the Arduino project began in response to the need for affordable and easy-to-use devices for Interaction Design students to use in their projects. It is said that Massimo Banzi and David Cuartielles named the project after Arduin of Ivera, an Italian king, but I’ve heard from reliable sources that it also happens to be the name of the local pub near the university, which may have been of more significance to the project.

The Arduino project drew from many of the experiences of both Wiring and Processing. For example, an obvious influence from Processing is the graphic user interface (GUI) that is used in the Arduino software. This GUI was initially “borrowed” from Processing, and even though it still looks similar, it has since been refined to be more specific to Arduino. I cover the Arduino interface in more depth in Chapter 4.

Arduino also kept the naming convention from Processing, naming its programs sketches. In the same way that Processing gives people a digital sketchbook to create and test programs quickly, Arduino gives people a way to sketch out their hardware ideas as well. Throughout this book, I show many sketches that allow your Arduino to perform a huge variety of tasks. By using and editing the example sketches in this book, you can quickly build up your understanding of how they work and will be writing your own in no time. Each sketch is followed with a line-by-line explanation of how it works to ensure that no stone is left unturned.

The Arduino board, shown in Figure 1-3, was made to be more robust and forgiving than Wiring or other earlier microcontrollers. It was not uncommon for students and professions, especially those from a design or arts background, to break their microcontroller within minutes of using it, simply by getting the wires the wrong way around. This fragility was a huge problem, not only financially but also for the success of the boards outside technical circles.

It is also possible to change the microcontroller chip on an Arduino, so if it is damaged, you can just replace the chip rather than the whole board.

Another important difference between Arduino and other microcontroller boards is the cost. In 2006, another popular microcontroller, the Basic Stamp, cost nearly four times as much (http://blog.makezine.com/2006/09/25/arduino-the-basic-stamp-k/) as an Arduino, and even today, a Wiring board still costs nearly double the price of an Arduino.

In one of my first Arduino workshops, I was told that the price was intended to be affordable for students. The price of a nice meal and a glass of wine at that time was about 30 euros, so if you had a project deadline, you could choose to skip a nice meal that week and make your project instead.

The range of Arduino boards on the market is a lot bigger than it was back in 2006. In Chapter 2, you learn about just a few of the most useful Arduino and Arduino-compatible boards and how they differ to provide you with a variety of solutions for your own projects. Also, in Chapter 13 you learn all about a special type of circuit board called a shield, which can add useful, and in some cases phenomenal, features to your Arduino, turning it into a GPS receiver, a Geiger counter, or even a mobile phone, to name just a few.

9781118446379-fg0103.tif

Figure 1-3: The original Arduino Serial board.

Learning by Doing

People have used technology in many ways to achieve their own goals without needing to delve into the details of electronics. Following are just a few related schools of thought that have allowed people to play with electronics.

Patching

Patching isn’t just a town in West Sussex; it is also a technique for experimenting with systems. The earliest popular example of patching is in phone switchboards. For an operator to put you through to another line they had to physically attach a cable. This was also a popular technique for synthesizing music, such as with the Moog synthesizer.

When an electronic instrument generates a sound, it is really generating a voltage. Different collections of components in the instrument manipulate that voltage before it is outputted as an audible sound. The Moog synthesizer works by changing the path that that voltage takes, sending it through a number of different components to apply different effects.

Because so many combinations are possible, for the musician the experience is largely based on trial and error. But the simple interface means that this process is extremely quick and requires very little preparation to get going.

Hacking

Hacking is popular term and is commonly used to refer to subversive people on the Internet. More generally, though, it refers to exploring systems and making full use of them or repurposing them to suit your needs.

Hacking in this sense is possible in hardware as well as software. A great example of hardware hacking is a keyboard hack. Say that you want to use a big, red button to move through a slideshow. Most software has keyboard shortcuts, and most PDF viewers move to the next page when the user presses the spacebar. If you know this, then you ideally want a keyboard with only a spacebar.

Keyboards have been refined so much that inside a standard keyboard is a small circuit board, a bit smaller than a credit card (see Figure 1-4). On it are lots of contacts that are connected when you press different keys. If you can find the correct combination, you can connect a couple of wires to the contacts and the other ends to a pushbutton. Now every time you hit that button, you send a space to your computer.

This technique is great for sidestepping the intricacies of hardware and getting the results you want. In the bonus chapter (www.dummies.com/go/arduinofd), you learn more about the joy of hacking and how you can weave hacked pieces of hardware into your Arduino project to control remote devices, cameras, and even computers with ease.

9781118446379-fg0104.tif

Figure 1-4: The insides of a keyboard, ready to be hacked.

Circuit bending

Circuit bending flies in the face of traditional education and is all about spontaneous experimentation. Children’s toys are the staple diet of circuit benders, but really any electronic device has the potential to be experimented with.

By opening a toy or device and revealing the circuitry, you can alter the path of the current to affect its behavior. Although this technique is similar to patching, it’s a lot more unpredictable. However, after you find the combinations, you can also add or replace components, such as resistors or switches, to give the user more control over the instrument.

Most commonly, circuit bending is about sound, and the finished instrument becomes a rudimentary synthesizer or drum machine. Two of the most popular devices are the Speak & Spell (see Figure 1-5) and the Nintendo GameBoy. Musicians such as the Modified Toy Orchestra (modifiedtoyorchestra.com ), in their own words, "explore the hidden potential and surplus value latent inside redundant technology." So think twice before putting your old toys on eBay!

9781118446379-fg0105.tif

Courtesy of Modified Toy Orchestra

Figure 1-5: A Modified Toy Orchestra Speak & Spell after circuit bending.

Electronics

Although there are many ways to work around technology, eventually you’ll want more of everything: more precision, more complexity, and more control.

If you learned about electronics at school, you were most likely taught how to build circuits using specific components. These circuits are based solely on the chemical properties of the components and need to be calculated in detail to make sure that the correct amount of current is going to the correct components.

These are the kind of circuits you find as kits at Radio Shack (or Maplin, in the United Kingdom) that do a specific job, such as an egg timer or a security buzzer that goes off when you open a cookie jar. These are very good at their specific job, but they can’t do much else.

This is where microcontrollers come in. Microcontrollers are tiny computers, and if used in conjunction with analog circuitry, can give that circuitry a more advanced behavior. They can also be reprogrammed to perform different functions as needed. Your Arduino is actually designed around one of these microcontrollers and helps you get the most out of it. In Chapter 2, you look closely at an Arduino Uno to see exactly how it is designed and what it is capable of.

The microcontroller is the brains of a system, but it needs data to either sense things about or affect things in its environment. It uses inputs and outputs to do so.

Inputs

Inputs are senses for your Arduino. They tell it what is going on in the world. At its most basic, an input could be a switch, such as a light switch in your home. At the other end of the spectrum, it could be a gyroscope, telling the Arduino the exact direction it’s facing in three dimensions. You learn all about basic inputs in Chapter 7, and more about the variety of sensors and when to use them in Chapter 12.

Outputs

Outputs allow your Arduino to affect the real world in some way. An output could be very subtle and discreet, such as in the same way that a mobile phone vibrates, or it could be a huge visual display on the side of a building that can be seen for miles around. The first sketch in the book walks you through “blinking” an LED (see Chapter 4). From there you can go on to motor control (Chapter 8) and even controlling huge numbers of outputs (see Chapters 14 and 15) to discover a variety of outputs for your Arduino project.

Open Source

Open source software, in particular Processing, has had a huge influence on the development of Arduino. In the world of computer software, open source is a philosophy involving sharing the details of a program and encouraging others to use, remix, and redistribute them, as they like.

Just as the Processing software is open source, so are Arduino software and hardware. This means that the Arduino software and hardware are both released freely to be adapted as needed. Possibly because of this openness on the part of the Arduino team, you find the same open source community spirit in the Arduino forums.

On the official Arduino forums (www.arduino.cc/forum/) and many other ones around the world, people have shared their code, projects, and questions for an informal peer review. This sharing allows all sorts of people, including experienced engineers, talented developers, practiced designers, and innovative artists, to lend their expertise to complete novices in some or all of these areas. It also provides a means to gauge people's areas of interest, which then occasionally filters into the official release of Arduino software or board design with new refinements or additions. The Arduino website has an area known as the Playground (www.playground.arduino.cc) where people are free to upload their code for the community to use, share, and edit.

This kind of philosophy has encouraged the relatively small community to pool knowledge on forums, blogs, and websites, thereby creating a vast resource for new Arduin-ists to tap into.

There is also a strange paradox that despite the open source nature of Arduino, a huge loyalty to Arduino as a brand exists — so much so that there is an Arduino naming convention of adding -duino or -ino to the name of boards and accessories (much to the disgust of Italian members of the Arduino team)!