Android Development For Arduino 101
By: Bryan Jones Richardson
Software Engineer
stable|kernel

bryan.richardson@stablekernel.com
stablekernel.com
We’re stable|kernel.
stable|kernel is an Atlanta-based mobile development company 

to craft smartly-designed mobile applications that connect brands 

directly with their users. 



The Internet of Things?
@stablekernel
@stablekernel
The internet of things (IoT) is the
network of physical devices,
embedded with electronics, software,
sensors, actuators, and network
connectivity that enable them to
collect and exchange data.
• Transportation (Street Lights)
• Healthcare
• Agriculture
• Durables & Wearable
• Object Oriented World
What Is Arduino?
@stablekernel
@stablekernel
Arduino is an open-source electronics
platform based on easy-to-use hardware
and software. It's intended for anyone
making interactive projects.
(Basically, a small computer that you can
connect to anything).
• Uno
• Mega
• Yun
• Minimal Cost Barriers
• Raspberry Pi, Edison, etc.
Connect.Tech- Android Development For Arduino 101
Connect.Tech- Android Development For Arduino 101
Let’s Make Music
@stablekernel
Arduino Communication Strategies
@stablekernel
•USB
•Bluetooth
•Network
Android & Arduino via USB
@stablekernel
@stablekernel
Android USB Classes
• UsbManager
• UsbDevice
• UsbDeviceConnection
• UsbInterface
• UsbEndpoint
• UsbConstants
@stablekernel
Detect Android USB Connection
private final BroadcastReceiver usbConnectionAttachedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(@NonNull Context context, @NonNull Intent intent) {
activeUsbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
connectUsb();
}
};
private final BroadcastReceiver usbConnectionDetachedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(@NonNull Context context, @NonNull Intent intent) {
UsbDevice detachedDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (detachedDevice == activeUsbDevice) {
disconnectUsb();
}
}
};
@stablekernel
Determine if Arduino is Connected
for (int i = 0; i < activeUsbDevice.getInterfaceCount(); i++) {
UsbInterface usbInterface = activeUsbDevice.getInterface(i);
if (usbInterface.getEndpointCount() == 2) {
for (int j = 0; j < endpointCount; j++) {
UsbEndpoint endpoint = usbInterface.getEndpoint(j);
if (endpoint.getType() != UsbConstants.USB_ENDPOINT_XFER_BULK) {
continue;
}
if (endpoint.getDirection() == UsbConstants.USB_DIR_OUT) {
endpointOut = usbInterface.getEndpoint(j);
} else if (endpoint.getDirection() == UsbConstants.USB_DIR_IN) {
endpointIn = usbInterface.getEndpoint(j);
}
}
}
}
}
@stablekernel
Establish Communication w/ Arduino
private void setupUSBComm() {
UsbManager manager = (UsbManager) getActivity().getSystemService(Context.USB_SERVICE);
Boolean permitToRead = manager.hasPermission(arduinoDevice);
if (permitToRead) {
connection = manager.openDevice(arduinoDevice);
if (connection != null) {
connection.claimInterface(activeUSBInterface, true);
//requestType, SET_CONTROL_LINE_STATE, value, index, buffer, length, timeout
connection.controlTransfer(RQSID_SET_REQUEST_TYPE, RQSID_SET_CONTROL_LINE_STATE, 0, 0, null, 0, 0);
connection.controlTransfer(RQSID_SET_REQUEST_TYPE, RQSID_SET_LINE_CODING, 0, 0, encodingSetting, 7, 0);
}
} else {
manager.requestPermission(arduinoDevice, permissionIntent);
}
}
@stablekernel
Send Android Data to Arduino
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
playNote(position);
}
public void playNote(int note_value) {
byte[] bytesOut = new byte[]{ (byte) note_value};
if(arduinoDevice != null) {
usbArduinoConnection.bulkTransfer(endpointOut, bytesOut, 1, 0);
}
}
@stablekernel
Process Android Data on Arduino
int speakerPin = 9;
int tones[] = { 440, 494, 523, 587, 659, 698, 784};
void setup() {
pinMode(speakerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
int incomingByte = Serial.read();
if (incomingByte > -1) {
playNote(incomingByte);
}
}
}
void playNote(int note) {
tone(speakerPin, tones[note], 200);
}
@stablekernel
Hardware Setup
Ground Pin 9
Piezo BreadBoardUno USB
Android & Arduino via Bluetooth
@stablekernel
@stablekernel
Android Bluetooth Classes
<uses-permission android:name = "android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name = “android.permission.BLUETOOTH”/>
private BluetoothAdapter bluetoothAdapter;
private BluetoothSocket bluetoothSocket;
private Set<BluetoothDevice> pairedBluetoothDevices;
static final UUID myUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
@stablekernel
Connect To BlueTooth Device
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothDevice btDevice = bluetoothAdapter.getRemoteDevice(bluetoothAddress);
btSocket = btDevice.createInsecureRfcommSocketToServiceRecord(myUUID);
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
btSocket.connect();
@stablekernel
Send Android Data to Arduino
byte[] bytesOut = new byte[]{ note_value };
try {
btSocket.getOutputStream().write(bytesOut);
} catch (IOException e) {
// handle exception
}
@stablekernel
Debugging on Arduino
@stablekernel
Debugging on Arduino
digitalWrite(ledPin, LOW);
digitalWrite(ledPin, HIGH);
serialPrint(…);
@stablekernel
Hardware Setup
Bluetooth
Transmitter
LED
Android & Arduino via Network
@stablekernel
@stablekernel
Configure Yun For Connectivity
@stablekernel
Configure Yun For Connectivity
@stablekernel
Configure Yun For Connectivity
@stablekernel
Implement Arduino Code
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
YunServer server;
...
@stablekernel
Implement Arduino Code
void setup() {
...
Bridge.begin();
server.listenOnLocalhost();
server.begin();
}
@stablekernel
Implement Arduino Code
void loop() {
YunClient client = server.accept();
if (client) {
process(client);
client.stop();
}
delay(50);
}
void process(YunClient client) {
String incomingNote = client.readStringUntil('/');
playNote(incomingNote.toInt());
}
@stablekernel
Send Android Data to Arduino Yun
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
String[] musicalNotes = new String[] { "A","B","C","D","E","F","G"};
ArrayAdapter<String> musicalNotesAdapter = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1, musicalNotes);
notesListView.setOnItemClickListener(this);
notesListView.setAdapter(musicalNotesAdapter);
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String note = String.valueOf(position);
HttpClient client = new DefaultHttpClient();
String URL = “http://10.0.0.19/arduino/“ + note;
HttpGet request = new HttpGet(URL);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
client.execute(httpget, responseHandler);
}
@stablekernel
Hardware Setup
Live Demo
@stablekernel
Questions?
Business Inquiries:
Sarah Woodward
Director of Business Development
sarah.woodward@stablekernel.com
Bryan Jones Richardson
Software Engineer
bryan.richardson@stablekernel.cm
blog.stablekernel.com

More Related Content

PPTX
DIY Science using the Intel IoT Developer Kit
PDF
Overview of the Intel® Internet of Things Developer Kit
PDF
Internet of Things - Technicals
PPTX
How to program software and objects
PDF
Intel Curie Presentation
PDF
Introduction to AIoT & TinyML - with Arduino
PDF
Pre meetup intel® roadshow london
PDF
Arduino 101
DIY Science using the Intel IoT Developer Kit
Overview of the Intel® Internet of Things Developer Kit
Internet of Things - Technicals
How to program software and objects
Intel Curie Presentation
Introduction to AIoT & TinyML - with Arduino
Pre meetup intel® roadshow london
Arduino 101

What's hot (20)

PPTX
Arduino Programming Software Development
PDF
Iot development from prototype to production
PPT
Introduction To Arduino
PDF
Arduino Based Smart Parking System
PDF
Show & Tell.- Introduction
PDF
Echelon Indonesia 2016 - Innovation Through Opportunities in IoT & Arduino
PDF
Microcontrollers (Rex St. John)
PDF
Embedded system introduction - Arduino Course
PPTX
Introduction to Arduino
PPTX
Intro to Arduino.ppt
PPTX
WHD global 2017 - Smart Power Plant
PPTX
Wi-Fi Esp8266 nodemcu
PPTX
Particle Core
PPTX
Arduino day
PPT
Arduino and Internet of Thinks: ShareIT TM: march 2010, TM
PDF
Analog to Digital Conversion Using Microcontroller Education Boards
PDF
Introducing the Arduino
PPTX
Brain controlled robot
PPTX
Microcontroller arduino uno board
PDF
Internet of Things
Arduino Programming Software Development
Iot development from prototype to production
Introduction To Arduino
Arduino Based Smart Parking System
Show & Tell.- Introduction
Echelon Indonesia 2016 - Innovation Through Opportunities in IoT & Arduino
Microcontrollers (Rex St. John)
Embedded system introduction - Arduino Course
Introduction to Arduino
Intro to Arduino.ppt
WHD global 2017 - Smart Power Plant
Wi-Fi Esp8266 nodemcu
Particle Core
Arduino day
Arduino and Internet of Thinks: ShareIT TM: march 2010, TM
Analog to Digital Conversion Using Microcontroller Education Boards
Introducing the Arduino
Brain controlled robot
Microcontroller arduino uno board
Internet of Things
Ad

Similar to Connect.Tech- Android Development For Arduino 101 (20)

PPTX
Android Open Accessory APIs
PDF
Android Things, from mobile apps to physical world
PDF
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
PDF
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
PDF
Android Things in action
PDF
Android project
ODP
Android Based Robots
PPT
Development, debug and deploy hardware/software solutions based on Android an...
PDF
Android + arduino = love @ Droidcon Bucharest 2012
PDF
Comunicação Android Arduino - JASI 2015
PDF
Smartphone++
PPT
Arduino Meetup with Sonar and 433Mhz Radios
PDF
Android Things Linux Day 2017
PPT
Arduino final ppt
PPTX
ควบคุมบอร์ดArduinoผ่านระบบandroid
PDF
Programming objects with android
PDF
Mobile Development For Arduino 201 - ConnectTech
PDF
Hack the Real World with ANDROID THINGS
PDF
Connecting outsideworld with Android and Arduino
DOCX
Wireless E-Notice Board Using Bluetooth Report.docx
Android Open Accessory APIs
Android Things, from mobile apps to physical world
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
Android Things in action
Android project
Android Based Robots
Development, debug and deploy hardware/software solutions based on Android an...
Android + arduino = love @ Droidcon Bucharest 2012
Comunicação Android Arduino - JASI 2015
Smartphone++
Arduino Meetup with Sonar and 433Mhz Radios
Android Things Linux Day 2017
Arduino final ppt
ควบคุมบอร์ดArduinoผ่านระบบandroid
Programming objects with android
Mobile Development For Arduino 201 - ConnectTech
Hack the Real World with ANDROID THINGS
Connecting outsideworld with Android and Arduino
Wireless E-Notice Board Using Bluetooth Report.docx
Ad

Recently uploaded (20)

PDF
Mobile App for Guard Tour and Reporting.pdf
PPTX
HackYourBrain__UtrechtJUG__11092025.pptx
PPTX
SmartGit 25.1 Crack + (100% Working) License Key
PDF
infoteam HELLAS company profile 2025 presentation
DOCX
Industrial Bio-Lynx: Advanced Biometric Solution for Workforce Management
PPTX
Chapter 1 - Transaction Processing and Mgt.pptx
PDF
MAGIX Sound Forge Pro CrackSerial Key Keygen
PDF
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
PDF
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
PPTX
Human-Computer Interaction for Lecture 1
PDF
CapCut PRO for PC Crack New Download (Fully Activated 2025)
PDF
IT Consulting Services to Secure Future Growth
PPTX
Post-Migration Optimization Playbook: Getting the Most Out of Your New Adobe ...
PDF
Cloud Native Aachen Meetup - Aug 21, 2025
PPTX
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
PDF
Top 10 Project Management Software for Small Teams in 2025.pdf
PPTX
Viber For Windows 25.7.1 Crack + Serial Keygen
PPT
3.Software Design for software engineering
PPTX
ROI from Efficient Content & Campaign Management in the Digital Media Industry
PPTX
Lecture 5 Software Requirement Engineering
Mobile App for Guard Tour and Reporting.pdf
HackYourBrain__UtrechtJUG__11092025.pptx
SmartGit 25.1 Crack + (100% Working) License Key
infoteam HELLAS company profile 2025 presentation
Industrial Bio-Lynx: Advanced Biometric Solution for Workforce Management
Chapter 1 - Transaction Processing and Mgt.pptx
MAGIX Sound Forge Pro CrackSerial Key Keygen
PDF-XChange Editor Plus 10.7.0.398.0 Crack Free Download Latest 2025
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
Human-Computer Interaction for Lecture 1
CapCut PRO for PC Crack New Download (Fully Activated 2025)
IT Consulting Services to Secure Future Growth
Post-Migration Optimization Playbook: Getting the Most Out of Your New Adobe ...
Cloud Native Aachen Meetup - Aug 21, 2025
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
Top 10 Project Management Software for Small Teams in 2025.pdf
Viber For Windows 25.7.1 Crack + Serial Keygen
3.Software Design for software engineering
ROI from Efficient Content & Campaign Management in the Digital Media Industry
Lecture 5 Software Requirement Engineering

Connect.Tech- Android Development For Arduino 101

  • 1. Android Development For Arduino 101 By: Bryan Jones Richardson Software Engineer stable|kernel
 [email protected] stablekernel.com
  • 2. We’re stable|kernel. stable|kernel is an Atlanta-based mobile development company 
 to craft smartly-designed mobile applications that connect brands 
 directly with their users. 
 

  • 3. The Internet of Things? @stablekernel
  • 4. @stablekernel The internet of things (IoT) is the network of physical devices, embedded with electronics, software, sensors, actuators, and network connectivity that enable them to collect and exchange data. • Transportation (Street Lights) • Healthcare • Agriculture • Durables & Wearable • Object Oriented World
  • 6. @stablekernel Arduino is an open-source electronics platform based on easy-to-use hardware and software. It's intended for anyone making interactive projects. (Basically, a small computer that you can connect to anything). • Uno • Mega • Yun • Minimal Cost Barriers • Raspberry Pi, Edison, etc.
  • 11. Android & Arduino via USB @stablekernel
  • 12. @stablekernel Android USB Classes • UsbManager • UsbDevice • UsbDeviceConnection • UsbInterface • UsbEndpoint • UsbConstants
  • 13. @stablekernel Detect Android USB Connection private final BroadcastReceiver usbConnectionAttachedReceiver = new BroadcastReceiver() { @Override public void onReceive(@NonNull Context context, @NonNull Intent intent) { activeUsbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); connectUsb(); } }; private final BroadcastReceiver usbConnectionDetachedReceiver = new BroadcastReceiver() { @Override public void onReceive(@NonNull Context context, @NonNull Intent intent) { UsbDevice detachedDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); if (detachedDevice == activeUsbDevice) { disconnectUsb(); } } };
  • 14. @stablekernel Determine if Arduino is Connected for (int i = 0; i < activeUsbDevice.getInterfaceCount(); i++) { UsbInterface usbInterface = activeUsbDevice.getInterface(i); if (usbInterface.getEndpointCount() == 2) { for (int j = 0; j < endpointCount; j++) { UsbEndpoint endpoint = usbInterface.getEndpoint(j); if (endpoint.getType() != UsbConstants.USB_ENDPOINT_XFER_BULK) { continue; } if (endpoint.getDirection() == UsbConstants.USB_DIR_OUT) { endpointOut = usbInterface.getEndpoint(j); } else if (endpoint.getDirection() == UsbConstants.USB_DIR_IN) { endpointIn = usbInterface.getEndpoint(j); } } } } }
  • 15. @stablekernel Establish Communication w/ Arduino private void setupUSBComm() { UsbManager manager = (UsbManager) getActivity().getSystemService(Context.USB_SERVICE); Boolean permitToRead = manager.hasPermission(arduinoDevice); if (permitToRead) { connection = manager.openDevice(arduinoDevice); if (connection != null) { connection.claimInterface(activeUSBInterface, true); //requestType, SET_CONTROL_LINE_STATE, value, index, buffer, length, timeout connection.controlTransfer(RQSID_SET_REQUEST_TYPE, RQSID_SET_CONTROL_LINE_STATE, 0, 0, null, 0, 0); connection.controlTransfer(RQSID_SET_REQUEST_TYPE, RQSID_SET_LINE_CODING, 0, 0, encodingSetting, 7, 0); } } else { manager.requestPermission(arduinoDevice, permissionIntent); } }
  • 16. @stablekernel Send Android Data to Arduino @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { playNote(position); } public void playNote(int note_value) { byte[] bytesOut = new byte[]{ (byte) note_value}; if(arduinoDevice != null) { usbArduinoConnection.bulkTransfer(endpointOut, bytesOut, 1, 0); } }
  • 17. @stablekernel Process Android Data on Arduino int speakerPin = 9; int tones[] = { 440, 494, 523, 587, 659, 698, 784}; void setup() { pinMode(speakerPin, OUTPUT); Serial.begin(9600); } void loop() { if (Serial.available()) { int incomingByte = Serial.read(); if (incomingByte > -1) { playNote(incomingByte); } } } void playNote(int note) { tone(speakerPin, tones[note], 200); }
  • 18. @stablekernel Hardware Setup Ground Pin 9 Piezo BreadBoardUno USB
  • 19. Android & Arduino via Bluetooth @stablekernel
  • 20. @stablekernel Android Bluetooth Classes <uses-permission android:name = "android.permission.BLUETOOTH_ADMIN"/> <uses-permission android:name = “android.permission.BLUETOOTH”/> private BluetoothAdapter bluetoothAdapter; private BluetoothSocket bluetoothSocket; private Set<BluetoothDevice> pairedBluetoothDevices; static final UUID myUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
  • 21. @stablekernel Connect To BlueTooth Device bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice btDevice = bluetoothAdapter.getRemoteDevice(bluetoothAddress); btSocket = btDevice.createInsecureRfcommSocketToServiceRecord(myUUID); BluetoothAdapter.getDefaultAdapter().cancelDiscovery(); btSocket.connect();
  • 22. @stablekernel Send Android Data to Arduino byte[] bytesOut = new byte[]{ note_value }; try { btSocket.getOutputStream().write(bytesOut); } catch (IOException e) { // handle exception }
  • 24. @stablekernel Debugging on Arduino digitalWrite(ledPin, LOW); digitalWrite(ledPin, HIGH); serialPrint(…);
  • 26. Android & Arduino via Network @stablekernel
  • 30. @stablekernel Implement Arduino Code #include <Bridge.h> #include <YunServer.h> #include <YunClient.h> YunServer server; ...
  • 31. @stablekernel Implement Arduino Code void setup() { ... Bridge.begin(); server.listenOnLocalhost(); server.begin(); }
  • 32. @stablekernel Implement Arduino Code void loop() { YunClient client = server.accept(); if (client) { process(client); client.stop(); } delay(50); } void process(YunClient client) { String incomingNote = client.readStringUntil('/'); playNote(incomingNote.toInt()); }
  • 33. @stablekernel Send Android Data to Arduino Yun @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); String[] musicalNotes = new String[] { "A","B","C","D","E","F","G"}; ArrayAdapter<String> musicalNotesAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, musicalNotes); notesListView.setOnItemClickListener(this); notesListView.setAdapter(musicalNotesAdapter); } @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String note = String.valueOf(position); HttpClient client = new DefaultHttpClient(); String URL = “http://10.0.0.19/arduino/“ + note; HttpGet request = new HttpGet(URL); ResponseHandler<String> responseHandler = new BasicResponseHandler(); client.execute(httpget, responseHandler); }
  • 36. Questions? Business Inquiries: Sarah Woodward Director of Business Development [email protected] Bryan Jones Richardson Software Engineer [email protected] blog.stablekernel.com