Synopses & Reviews
The book will have three kinds of content: explanatory sections, short examples, and projects. The explanatory sections explain the hardware and software concepts behind AOA, the ADK, and Arduino. The short examples provide short but fully-functional code designed to perform exactly one function (such as measure external temperature and display it on the screen of the Android device). The projects are longer, more in-depth examples of fully-functional programs with well-commented code along with the narrative. The book covers:
1. Introduction to Android Open Accessory (AOA)
2. Setting up the hardware
3. Setting up the development environments
4. Coding the Android half of your accessory
5. Coding the Arduino half of your accessory
6. Projects
a. Control your home sound system
b. Infrared transceivers for data transfer
c. A gamepad for your Android phone: Interfacing with keyboards, joysticks, and similar input devices
d. Exercycle exercise tracker
This book will give a nuts-and-bolts overview of all parts of Android Open Accessory. It will show how to get up and running for the Android part of AOA, common microcontroller and shield hardware, and for various sensors (inputs, e.g. temperature sensor) and indicators/actuators (outputs, e.g. lights/motors).
The reader will learn about wireless communication, digital sensors, and programming techniques to maximize their use of AOA with Arduino. The book will be accompanied with the source code for all the projects so readers can refer to it for their particular project.
This book targets Android developers that have done some Android coding (though they don't need to be very experienced-simply a knowledge of Activities, Views, and Intents would be sufficient) and may have a high school physics level understanding of electronics (knowing the very basics such as voltage, current, resistors, and capacitors) but need a brush-up on the theory and may have never built a circuit. Hackers and DIYers (do-it-yourselfers) who may have made plenty of electronic hardware can still get a lot of utility from the book, but they may need to do a few short tutorials on Android programming first. (A section in the book will describe how to get up to speed on the Android half of the coding.)
Synopsis
Learn how to control your home or car from your Android smartphone - air conditioning, lights, entertainment systems, and more!Android Open Accessory is a new, simple, and secure protocol for connecting any microcontroller-empowered device to an Android smartphone or tablet. This Wrox guide shows Android programmers how to use AOA with Arduino, the microcontroller platform, to control such systems as lighting, air conditioning, and entertainment systems from Android devices. Furthermore, it teaches the circuit-building skills needed to create games and practical products that also take advantage of Android technology.
- Introduces Android Open Accessory and shows how to set up the hardware and development environment
- Explains how to code both Android and Arduino elements of an accessory
- Features four complete projects developers can build using various sensors and indicators/actuators, including source code
- Gives Android developers the tools to create powerful, sophisticated projects
Professional Android Open Accessory with Android ADK and Arduino opens exciting new opportunities for Android developers.
Synopsis
An innovative approach to using your smartphone for home automationAndroid Open Accessory (AOA) is a simple and secure protocol for connecting any microcontroller-empowered device to an Android smartphone or tablet. This unique book shows you how to use AOA with Arduino, the microcontroller platform, in order to automate everyday tasks in your homesuch as lighting, air conditioning, and entertainment systemswith your smartphone. Assuming basic knowledge of the Android framework, this visionary author duo provides you with the tools you need to create powerful, sophisticated projects. Detailed explanations, helpful examples, and accessible prototypes all contribute to empowering you to take full advantage of Android technology.
Professional Android Open Accessory Programming with Arduino:
- Reviews the various options available for connecting an Arduino-based prototype to an Android phone
- Covers the basics of data communication and introduces MQTT
- Guides you through setting up both Android and Arduino
- Demonstrates how to build an Android library and create Android accessory applications
- Describes the processes for building each of the featured projects, using various sensors and indicators/actuators
wrox.com
Programmer Forums
Join our Programmer to Programmer forums to ask and answer programming questions about this book, join discussions on the hottest topics in the industry, and connect with fellow programmers from around the world.
Code Downloads
Take advantage of free code samples from this book, as well as code samples from hundreds of other books, all ready to use.
Read More
Find articles, ebooks, sample chapters, and tables of contents for hundreds of books, and more reference resources on programming topics that matter to you.
About the Author
Andreas Goransson has created a set of libraries and tools for Arduino ADK boards to communicate easily over USB with Android devices, in collaboration with David Cuartielles Ruiz. He is an active contributor to popular programming communities, where he creates both tools and libraries.
David Cuartielles Ruiz is co-founder of the Arduino prototyping platform and head of the Prototyping Laboratory at K3, Malmo University, Sweden. Together with Andreas Goransson, he has written libraries that enable Arduino to communicate with Android phones over Bluetooth.
Wrox Professional guides are planned and written by working programmers to meet the real-world needs of programmers, developers, and IT professionals. Focused and relevant, they address the issues technology professionals face every day. They provide examples, practical solutions, and expert education in new technologies, all designed to help programmers do a better job.
Table of Contents
INTRODUCTION xxiPART I: WELCOME TO THE WONDERFUL WORLD OF ACCESSORIESCHAPTER 1: INTRODUCTION TO ANDROID OPEN ACCESSORY 3I, Android 3
The Three Laws of Android 4
The Android Philosophy 6
Other Popular Systems 7
Preinstalled Applications 8
What Is Android Open Accessory? 9
Android USB in Short 9
Developing Android Accessories 10
What Is Arduino? 10
How Does AOA Work with Arduino? 11
What Can You Do with AOA? 12
What Can’t You Do with AOA? 13
Why it Matters that Google Chose Arduino 14
Summary 15
CHAPTER 2: SETTING UP THE (ARDUINO) HARDWARE 17Choosing Microcontroller Boards for Your Project 18
One Platform, Many Architectures 18
Shields 26
Choosing Sensors and Actuators for Your Project 29
Sensors 30
Actuators 34
Powering up Your Project 38
Ways to Power up Your Project 38
Arduino Feeding Your Phone 41
Summary 41
CHAPTER 3: UNDERSTANDING DATA COMMUNICATION 43Data Communication Basics 43
Protocols 44
Terminology 45
Hardware Layer for the Communication Protocol 47
ADB 47
Accessory Mode 48
Host Mode 48
TCP/IP 50
Audio Port 52
Bluetooth Options 53
Introducing MQTT 54
Heads Up! 55
MQTT Messages 58
P2PMQTT: A Modifi ed MQTT 63
Establishing a Connection 63
Subscribing to a Topic 63
Publishing a Message 64
Disconnecting 64
Summary 64
CHAPTER 4: SETTING UP DEVELOPMENT ENVIRONMENTS 67Setting up Android Development 67
Android Development Environment 69
Hello, Android! 79
Setting up Arduino Development 80
Arduino Development Environment 80
Hello, Arduino! 82
Hello Open Accessory App 85
The Temperature Sensor 85
The Arduino Sketch 87
The Android Project 88
Ready to Go 88
Summary 89
CHAPTER 5: CREATING THE ACCESSORY LIBRARY 91Getting Started with Android Libraries 92
Building the P2PMQTT Library 92
Preparing the Library Project 92
Sketching the API 93
Implementing MQTT 94
Decoding MQTT 108
Managing Open Accessory Connections 117
Creating the Connection Class 117
USB Connection 119
Bluetooth Connection 123
Creating the Connection 126
Summary 131
CHAPTER 6: USING YOUR ACCESSORY LIBRARY 133Using Custom Android Libraries 133
The WroxAccessories Library 134
Building the Mini Projects 137
The LSMSD 137
The Parking Assistant 145
The Basic Robot 154
The Sampler 164
Summary 170
CHAPTER 7: DIGITAL ARDUINO 171Digital Actuators 172
The Blinking LEDs 172
Controlling a Desk Lamp — The Relay 178
Digital Project 1: Large SMS Display 182
Writing the Arduino Program 186
Digital Sensors 190
Buttons and Switches 190
Tilt Sensor 194
Digital Project 2: Small Sampler 197
Summary 202
CHAPTER 8: ANALOG ARDUINO 205Analog Actuators 206
The Piezo Element 207
Motors 211
Analog Project 1: The Basic Robot 215
Analog Sensors 223
Potentiometers 224
Ultrasound Sensors 228
Analog Project 2: The Parking Assistant 233
Summary 239
PART II: PROJECTSCHAPTER 9: BIKE RIDE RECORDER 243The Concept Behind Bike Computers 244
The Design Brief 245
Working with the Arduino Side 246
Creating the Hardware and Mechanics 247
Programming the Bike Computer 251
Building the Android App 259
Creating the Bike Ride Recorder Project 260
Creating the User Interface 261
Setting up the AoaService 266
Building the Main Menu Activity 271
Building the Recording Activity 271
Building the List Recordings View 282
Building the Playback View Activity 285
Making Further Improvements 290
Mechanics 290
More Sensors 290
Making a Better App 290
Summary 291
CHAPTER 10: KITCHEN LAMP 293The Concept 293
The Design Brief 295
The Arduino Side 296
Hardware 298
Software 301
Building The Android App 307
Sketching the Application Layout 307
Create the Kitchen Lamp Project 308
Create the User Interface 308
Building the Kitchen Timer 313
Responding to Phone Calls 315
Listen for SMS Events 319
Connecting to the WroxAccessory 322
Further Improvements 325
Product-ready Embedded System 326
Making a Better App 326
Summary 327
CHAPTER 11: MR. WILEY 329The Concept 330
The Design Brief 331
The Arduino Side 332
The Hardware 332
The Firmware (on the Robot Board) 335
Creating Software for the Mega ADK Board 340
Building the Android App 342
Sketching the Application Layout 343
Creating the Mr. Wiley Project 343
Building the Computer Vision Algorithm 348
Connecting to the WroxAccessory 358
Making Further Improvements 364
Electronics 364
Making a Better App 364
Summary 364INDEX 365