concept SenseBot application in category android

appears as: SenseBot application, The SenseBot application
Android in Action, Third Edition

This is an excerpt from Manning's book Android in Action, Third Edition.

The code accompanying this chapter is organized into an Android application named SenseBot. SenseBot is a moderately complex example of using Android to manipulate an external object. Android’s orientation sensor permits the user to “drive” the robot by simply holding the phone in a particular direction, not unlike a Nintendo Wii or other advanced gaming system. Tilt the phone forward, and the robot drives forward. Tilt it backward, and the robot reverses direction. Tilting to the left or right causes the robot to spin in the respective direction. With each interpreted sensor motion, the SenseBot application uses Bluetooth to send commands to the robot, causing the appropriate physical behavior. The LEGO NXT comes equipped with a built-in command set that permits low-level operations such as direct motor control. The motions of the Android device are interpreted, converted to commands, and transmitted via Bluetooth to the robot.

14.3. Building the SenseBot application

The SenseBot application has a simple premise—you want to drive a LEGO Mindstorms NXT[5] robot by changing the orientation of the Android phone. There are no attached wires—all the communication is done via Bluetooth, and the orientation of the phone alone should dictate how the robot moves. Furthermore, though the LEGO robot is programmable, you utilize only the built-in capabilities of the robot to manipulate individual motors. The benefit of this approach is that this program will work on virtually any LEGO robot built, regardless of the skill of the robot programmer. The only requirements of the robot are that the motors be connected to output ports B and C, which is the common manner of constructing LEGO NXT robots. Figure 14.5 shows the robot with a simple two-motor design.