Supplemental files and examples for this book can be found at http://examples.oreilly.com/0636920010371/. Please use a standard desktop web browser to access these files, as they may not be accessible from all ereader devices.
All code files or examples referenced in the book will be available online. For physical books that ship with an accompanying disc, whenever possible, weve posted all CD/DVD content. Note that while we provide as much of the media content as we are able via free download, we are sometimes limited by licensing restrictions. Please direct any questions or concerns to .
Preface
In the early days, embedded systems were built primarily by engineers in a pretty exclusive club. Embedded devices and software tools were expensive, and building a functional prototype required significant software engineering and electrical engineering experience.
With the arrival of Arduino, the open source electronics prototyping platform, things are cheaper and easier. The hardware is inexpensive (around $30), the software is free, and the Arduino environment is designed for artists, designers, and hobbyists rather than engineering professionals.
The ultimate goal of this book is to teach you how to build prototypes using Arduino. We'll offer just enough theory to help you apply your new skills to your own projects. You will also become familiar with the logic behind coding and components. We will explain every single line of code and tell you how each component is used. You will learn by completing actual projects, and the knowledge you gain will enable you to further develop your own ideas.
Most books on embedded systems are either so specialized that you need to work within the particular field or too simplistic to be interesting. Books for beginners often just teach you to blindly follow instructions; here, we aim to promote a deeper understanding and a skill set that can be applied more flexibly.
Finally, this book is meant for readers who want to learn how to build prototypes of interesting gadgets, not for those who want to build a dental X-ray machine or a microwave oven. At the same time, you will be able to apply the techniques covered in the book to make prototypes of commercial device concepts.
Embedded Systems Are Everywhere
An embedded system is a microcontroller-based device designed for a very specific purpose. Some examples include washing machines, cell phones, elevators, car brakes, GPS devices, air conditioning units, microwave ovens, wristwatches, and robotic vacuum cleaners. Unlike the user interface you're accustomed to with traditional computers, embedded systems typically do not include a display, mouse, and keyboard. Instead, you might control them via switches and foot pedals, for example.
Most embedded systems are reactive systems, operating in a continuous interaction with their environment and responding within a tempo defined by that environment. This makes them a logical choice for tasks that must react immediately, such as a car braking system.
In some cases, it can be hard to tell whether a particular system should be classified as an embedded system or a computer. For example, cell phones are starting to include more and more features typically associated with computers, but they still have much in common with embedded systems.
Why Should You Study Embedded Systems?
The world is already full of embedded systems. With reasonable effort, you can learn how to build one yourself. Turn inventions and ideas into inexpensive prototypes, automate your home by creating a fish-feeding device or controlling lighting from your computer, or build a remote-controlled surveillance camera for your yard that you can access via a computer located anywhere in the world. Artists can create interactive installations or integrate sensors into a game that you can control without touching a computer. Possible implementations are endless.
During the 2000s, the DIY meme gathered more and more popularity, as is evident with the growth of MAKE Magazine and websites such as http://www.instructables.com. The Bay Area Maker Faire, an annual DIY festival, went from 22,000 attendees in its first year (2006) to more than double that amount (45,000) in its second year. And each year, Maker Faire attendance keeps growing.
Learning embedded systems is becoming even more appealing due to the growing interest in robotics. In a 2006 Scientific American article,[] Microsoft founder Bill Gates predicted that robotics would be the next revolution within homes, comparing the current state of the robotics industry to the computing industry in the 1970s. Gates anticipates that robots will soon become a natural part of a home, taking care of simple tasks such as vacuum cleaning, lawn mowing, surveillance, and food service. In addition, because robots can be controlled remotely from anywhere, we'll be able to use them for telepresenceviewing, hearing, and touching people and things without even having to be present.
Intelligent Air Conditioning
The common use of embedded systems is not just the stuff of science fiction or future technology. It's already here and pervasive in the home. Consider air conditioning. A smart air conditioning system adjusts itself based on measurements. How does it know when the air is thick or stale?
Air conditioners measure the temperature, humidity, and sometimes also carbon dioxide levels using sensors. A microcontroller (a small, dedicated computer) follows these measurements, and if the air is damp, for example, it activates a servo that opens an air valve, letting fresh air flow in. This type of intelligent air control system has many benefits. It saves energy, because the air conditioning system doesn't need to be used at full power all the time, and it makes working in such a space more comfortable, because there's neither a constant draft nor stagnant air. The heating and air conditioning system at your own school or job likely functions on the same principles.