Arduino + Android Projects for the Evil Genius
To Linda. The love of my life.
About the Author
Simon Monk has a bachelors degree in Cybernetics and Computer Science and a doctorate in Software Engineering. He has been an active electronics hobbyist since his school days and is an occasional author in hobby electronics magazines. He is also author of 30 Arduino Projects for the Evil Genius and 15 Dangerously Mad Projects for the Evil Genius.
Acknowledgments
I THANK LINDA for giving me the time, space, and support to write this book and for putting up with the various messes my projects create around the house.
I also thank my boys, Stephen and Matthew Monk, for taking an interest in what their Dad is up to and their general assistance with project work.
Finally, I would like to thank Roger Stewart, Patricia Wallenburg, Mike McGee, and everyone at McGraw-Hill, who did a great job once again. Its a pleasure to work with such a great team.
Introduction
THIS IS A PROJECT BOOK that marries together the simple-to-use microcontroller boards (Arduino) and the world of Android mobile phones and tablet computers.
The book contains detailed instructions for constructing various projects that use Arduino and Android devices. Some of the projects, such as the Geiger Counter and the Ultrasonic Distance Meter, are essentially electronic accessories for your Android phone.
Other projects in the book work toward a home automation system, complete with electric door lock and a remote control for power and heating, making even home automation accessible from the Internet and your Android device.
Arduino
Arduino () is a small microcontroller board with a USB plug to connect to your computer and a number of connection sockets that can be wired up to external electronics such as motors, relays, light sensors, laser diodes, loudspeakers, microphones, and other items. They can either be powered through the USB connection from the computer, or from a battery or other power supply. They can be controlled from the computer or programmed by the computer and then disconnected and allowed to work independently.
Figure 1 An Arduino Uno board
The board design is open source. This means that anyone is allowed to make Arduino-compatible boards. Such competition has led to low costs.
The basic boards are supplemented by accessory shield boards that can be plugged on top of the Arduino board. In this book, we will use three shields: the USB master shield that allows us to connect to Android devices over USB; a motor shield for driving the wheels of a little robot; and an Ethernet shield that will allow us to turn our Arduino into a tiny web server.
The software for programming your Arduino is easy to use and also freely available for Windows, Mac, and Linux computers, at no cost.
Android
Android is Googles phone and tablet operating system. Developing for Android is free. The software development tools are free and there are no fees associated with distributing your app. You can also deploy directly without having to use Googles Market.
Apps for all the Android projects in the book, such as the one shown in . However, should you wish to modify the apps, the source code is also freely available from the web site.
Figure 2 The Geiger Counter app
Arduino and Android
Arduino is all about electronics connecting things together, but it lacks much in the way of a user interface and wireless connectivity. Android, on the other hand, has great user interface capabilities but no means of directly connecting to electronics.
Putting these two together, the Evil Genius can do great things!
Android Open Accessory
At Googles developer conference (Google IO 2011), the Open Accessory standard was announced. This is the standard for creating hardware accessories for Android devices that plug into the Android device through its USB connection. This is available for cell phones and tablets with Android 2.3.4 or later.
The really cool thing about this standard is that it is based around Arduino technology. Great news for Arduino enthusiasts and five of the projects in this book (Geiger Counter, Light Show, TV Remote, Temperature Logger, and Ultrasonic Range Finder) are Open Accessory projects.
The book introduces the concept of a Droid Duino Base, which takes an Arduinos microcontroller off the Arduino board and fits it into a socket on the prototyping area of a USB host shield. This removes the need for an Arduino for each project, reducing the size and keeping the cost down to a few tens of dollars per project. This forms the basis of four of the projects in the book and makes a handy module to reuse in your own Open Accessory projects.
Amarino
In some situations, a wired connection is not what is needed. For example, in the first project in this book (Bluetooth Robot), wires would really cramp the robots style. We can, however, use a clever bit of technology called Amarino that will allow us to remote control a small robot from an app on an Android phone.
Sound Interface
The second section of the book is concerned with building a home automation system using a low-cost Android tablet as the controller, which communicates with an Arduino device to provide the electronic interface. These tablets do not often have Bluetooth or Open Accessory capability, so a wired interface between the tablet and an Arduino is made using the audio jack.
This uses the same approach as the cassette tape interfaces employed by home computers in the 1980s.
The Book
All the projects in this book contain step-by-step construction details. All require some soldering, so a basic familiarity with soldering is required.
Schematic diagrams and layouts for stripboard or perfboard are provided.
All the Arduino sketches and Android apps are made freely available, so you do not need to know how to program. However, the software is explained for those who want to modify the designs or understand the basic principals before designing their own projects.
The book also includes an Android Open Accessory Primer appendix for those wishing to understand more about this framework and how to program it on both the Arduino and Android sides.
Projects
Each of the projects in this book is contained in its own chapter. Most of the projects can be built in isolation; however, the home automation projects of to be built.
The projects in this book are summarized in the following table on the next page.
The number of stars under the Difficulty column for each project will give you an idea of the ease of construction. The more stars, the more difficult the project. None of the projects require any surface-mount soldering or indeed anything finer than a 1/10-inch-pitch stripboard.
Next page