Chapter 14. Bluetooth and sensors
This chapter covers
- Connecting to a Bluetooth peripheral
- Interacting with the SensorManager
- Building and running the SenseBot application
The majority of the material presented in this book is concerned with employing various capabilities of the Android SDK. At this point, however, you’re going to see how to take advantage of an Android device’s hardware. Specifically, we’ll look at connecting an Android device to remote devices via a Bluetooth wireless connection, as well as reading and interpreting values from a hardware-based orientation sensor. This chapter combines these two hardware-related topics in a sample program that exercises control over a robot constructed from the popular LEGO Mindstorms NXT. The Mindstorms NXT robot supports a communications protocol known as Direct Commands,[1] allowing it to be controlled by a remote device. This is the one chapter of the book where you’ll want to have access to a physical Android device with version 2 or later of the operating system—the simulator alone isn’t adequate for exercising the Bluetooth and sensor functionality.
1 To learn more about Direct Commands for the LEGO Mindstorm, start here: http://mindstorms.lego.com/en-us/support/files/default.aspx.