The synergy between Arduino and Android platforms yields remarkable practical projects that elevate our everyday experiences. This shared drive is what united two authors from diverse backgrounds to collaborate on this book. We embrace the convergence of technology and reality, envisioning a future where technology seamlessly integrates into our daily routines.
To embark on the journey of Android application projects, it's highly beneficial to establish a fundamental project that encompasses the core stages of Android application development: crafting the application code and subsequently conducting testing on a physical Android device.
Setting up your first Hello Arduino project
Select "New Project" upon the launch of Android Studio, as illustrated in the screenshot below:
A crucial phase in the development of an Android application involves setting up your project. For this particular project, we've chosen Android 4.3 as the minimum target SDK. This version is essential because we plan to utilize the Bluetooth Low Energy API, which was introduced in Android 4.3. In this instance, we'll label the project as "Hello Arduino" and adopt your company's domain in reverse as the standard naming convention for the application package.Please consult the provided screenshot below:
For this specific project, we will proceed by selecting the simplest project option, which is the "Blank Activity," as depicted in the screenshot below. The alternative options offer additional features that are not required for our current stage.
In the screenshot below, we opt for the Blank Activity and are required to provide a name for our main Java file. We'll go with the name "MyActivity":
After completing the preceding stages, you'll arrive at this workspace. Here, you'll gain a comprehensive view of the project tree, the primary code editor, and the device displaying a preview of the User Interface (UI), as depicted in the subsequent screenshot: For this specific project, there is no requirement to make changes to the current code. As a result, we will move forward with constructing our application and deploying it on our tangible Android device.Installing your app on your physical device
Earlier, we established a connection and activated our tangible Android device using a USB connection. In Android Studio, the next step involves configuring the setup to execute our Android application.
To achieve this, navigate to the main toolbar and select "Editing Configurations," as illustrated in the screenshot below:
Within the Editing Configurations interface, we'll select the "+" icon and opt for "Android Application." Here, we'll configure the settings as follows and finalize them by clicking the OK button:
With all preparations in place, we're poised to launch the app. Select the previously established App configuration, then click on the Play button (depicted as a green triangle) as illustrated in the screenshot below:
It is conceivable to generate an Android Virtual Device (AVD) for application installation. Nevertheless, currently, no virtual emulators are equipped with Bluetooth functionality, a requirement for several projects in this book. Consequently, our attention will be directed towards configuring an Android physical device running Android 4.3 or a more recent version.
Moving forward, proceed by selecting your physical device and confirming with the OK button, as illustrated in the screenshot below:
If you have properly configured everything, anticipate seeing the following appear on your Android device:See also: