SlideShare a Scribd company logo
1 of 36
Download to read offline
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.
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

What's hot

Arduino Programming Software Development
Arduino Programming Software DevelopmentArduino Programming Software Development
Arduino Programming Software DevelopmentSanjay Kumar
 
Iot development from prototype to production
Iot development from prototype to productionIot development from prototype to production
Iot development from prototype to productionMender.io
 
Introduction To Arduino
Introduction To ArduinoIntroduction To Arduino
Introduction To Arduinounsheffield
 
Arduino Based Smart Parking System
Arduino Based Smart Parking SystemArduino Based Smart Parking System
Arduino Based Smart Parking SystemIRJET Journal
 
Show & Tell.- Introduction
Show & Tell.- IntroductionShow & Tell.- Introduction
Show & Tell.- Introductionzvikapika
 
Echelon Indonesia 2016 - Innovation Through Opportunities in IoT & Arduino
Echelon Indonesia 2016 - Innovation Through Opportunities in IoT & ArduinoEchelon Indonesia 2016 - Innovation Through Opportunities in IoT & Arduino
Echelon Indonesia 2016 - Innovation Through Opportunities in IoT & ArduinoAndri Yadi
 
Microcontrollers (Rex St. John)
Microcontrollers (Rex St. John)Microcontrollers (Rex St. John)
Microcontrollers (Rex St. John)Future Insights
 
Embedded system introduction - Arduino Course
Embedded system introduction - Arduino CourseEmbedded system introduction - Arduino Course
Embedded system introduction - Arduino CourseElaf A.Saeed
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to ArduinoYong Heui Cho
 
Arduino and Internet of Thinks: ShareIT TM: march 2010, TM
Arduino and Internet of Thinks: ShareIT TM: march 2010, TMArduino and Internet of Thinks: ShareIT TM: march 2010, TM
Arduino and Internet of Thinks: ShareIT TM: march 2010, TMAlexandru IOVANOVICI
 
Analog to Digital Conversion Using Microcontroller Education Boards
Analog to Digital Conversion Using Microcontroller Education BoardsAnalog to Digital Conversion Using Microcontroller Education Boards
Analog to Digital Conversion Using Microcontroller Education BoardsKyle VanDruten
 
Introducing the Arduino
Introducing the ArduinoIntroducing the Arduino
Introducing the ArduinoCharles A B Jr
 
Microcontroller arduino uno board
Microcontroller arduino uno boardMicrocontroller arduino uno board
Microcontroller arduino uno boardGaurav
 

What's hot (20)

Arduino Programming Software Development
Arduino Programming Software DevelopmentArduino Programming Software Development
Arduino Programming Software Development
 
Iot development from prototype to production
Iot development from prototype to productionIot development from prototype to production
Iot development from prototype to production
 
Introduction To Arduino
Introduction To ArduinoIntroduction To Arduino
Introduction To Arduino
 
Arduino Based Smart Parking System
Arduino Based Smart Parking SystemArduino Based Smart Parking System
Arduino Based Smart Parking System
 
Show & Tell.- Introduction
Show & Tell.- IntroductionShow & Tell.- Introduction
Show & Tell.- Introduction
 
Echelon Indonesia 2016 - Innovation Through Opportunities in IoT & Arduino
Echelon Indonesia 2016 - Innovation Through Opportunities in IoT & ArduinoEchelon Indonesia 2016 - Innovation Through Opportunities in IoT & Arduino
Echelon Indonesia 2016 - Innovation Through Opportunities in IoT & Arduino
 
Microcontrollers (Rex St. John)
Microcontrollers (Rex St. John)Microcontrollers (Rex St. John)
Microcontrollers (Rex St. John)
 
Embedded system introduction - Arduino Course
Embedded system introduction - Arduino CourseEmbedded system introduction - Arduino Course
Embedded system introduction - Arduino Course
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Intro to Arduino.ppt
Intro to Arduino.pptIntro to Arduino.ppt
Intro to Arduino.ppt
 
WHD global 2017 - Smart Power Plant
WHD global 2017 - Smart Power PlantWHD global 2017 - Smart Power Plant
WHD global 2017 - Smart Power Plant
 
Wi-Fi Esp8266 nodemcu
Wi-Fi Esp8266 nodemcu Wi-Fi Esp8266 nodemcu
Wi-Fi Esp8266 nodemcu
 
Particle Core
Particle Core Particle Core
Particle Core
 
Arduino day
Arduino dayArduino day
Arduino day
 
Arduino and Internet of Thinks: ShareIT TM: march 2010, TM
Arduino and Internet of Thinks: ShareIT TM: march 2010, TMArduino and Internet of Thinks: ShareIT TM: march 2010, TM
Arduino and Internet of Thinks: ShareIT TM: march 2010, TM
 
Analog to Digital Conversion Using Microcontroller Education Boards
Analog to Digital Conversion Using Microcontroller Education BoardsAnalog to Digital Conversion Using Microcontroller Education Boards
Analog to Digital Conversion Using Microcontroller Education Boards
 
Introducing the Arduino
Introducing the ArduinoIntroducing the Arduino
Introducing the Arduino
 
Brain controlled robot
Brain controlled robotBrain controlled robot
Brain controlled robot
 
Microcontroller arduino uno board
Microcontroller arduino uno boardMicrocontroller arduino uno board
Microcontroller arduino uno board
 
Internet of Things
Internet of ThingsInternet of Things
Internet of Things
 

Similar to Connect.Tech- Android Development For Arduino 101

Hack the Real World with ANDROID THINGS
Hack the Real World with ANDROID THINGSHack the Real World with ANDROID THINGS
Hack the Real World with ANDROID THINGSDevFest DC
 
Internet of things
Internet of thingsInternet of things
Internet of thingsBrockanurag
 
Internet of things - The Present & The Future
Internet of things - The Present & The FutureInternet of things - The Present & The Future
Internet of things - The Present & The Futureiotians
 
Taller IoT en la Actualidad
Taller IoT en la ActualidadTaller IoT en la Actualidad
Taller IoT en la ActualidadLaurence HR
 
Intel IoT Edge Computing 在 AI 領域的應用與商機
Intel IoT Edge Computing 在 AI 領域的應用與商機Intel IoT Edge Computing 在 AI 領域的應用與商機
Intel IoT Edge Computing 在 AI 領域的應用與商機Amazon Web Services
 
arduino 320126512170.pptx
arduino 320126512170.pptxarduino 320126512170.pptx
arduino 320126512170.pptxpriyaanaparthy
 
Global Azure Bootcamp 2016 - Real-world Internet of Things Backend with Azure...
Global Azure Bootcamp 2016 - Real-world Internet of Things Backend with Azure...Global Azure Bootcamp 2016 - Real-world Internet of Things Backend with Azure...
Global Azure Bootcamp 2016 - Real-world Internet of Things Backend with Azure...Andri Yadi
 
Bare metal Javascript & GPIO programming in Linux
Bare metal Javascript & GPIO programming in LinuxBare metal Javascript & GPIO programming in Linux
Bare metal Javascript & GPIO programming in LinuxAlexander Vanwynsberghe
 
How To Electrocute Yourself using the Internet
How To Electrocute Yourself using the InternetHow To Electrocute Yourself using the Internet
How To Electrocute Yourself using the InternetAlexander Roche
 
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
Getting Started with the Internet of Things  - Allianz Hackrisk Hackathon 29/...Getting Started with the Internet of Things  - Allianz Hackrisk Hackathon 29/...
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...The Internet of Things Methodology
 
ARUDINO UNO and RasberryPi with Python
 ARUDINO UNO and RasberryPi with Python ARUDINO UNO and RasberryPi with Python
ARUDINO UNO and RasberryPi with PythonJayanthi Kannan MK
 
Interoperability in Internet of Things (IOT)
Interoperability in Internet of Things (IOT)Interoperability in Internet of Things (IOT)
Interoperability in Internet of Things (IOT)manditalaskar123
 
RAHUL NASKAR IOT.ppt
RAHUL NASKAR IOT.pptRAHUL NASKAR IOT.ppt
RAHUL NASKAR IOT.pptPrakasBhowmik
 
Road to Republic of IoT - IoT Technologies & Machine Learning
Road to Republic of IoT - IoT Technologies & Machine LearningRoad to Republic of IoT - IoT Technologies & Machine Learning
Road to Republic of IoT - IoT Technologies & Machine LearningAndri Yadi
 
Introduction to iot and arduino uno r3
Introduction to iot and arduino uno r3Introduction to iot and arduino uno r3
Introduction to iot and arduino uno r3Saurav Chaudhary
 
Internet of things (IoT) with Azure
Internet of things (IoT) with AzureInternet of things (IoT) with Azure
Internet of things (IoT) with AzureVinoth Rajagopalan
 
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...Codemotion
 
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...Codemotion
 

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

Hack the Real World with ANDROID THINGS
Hack the Real World with ANDROID THINGSHack the Real World with ANDROID THINGS
Hack the Real World with ANDROID THINGS
 
Internet of things
Internet of thingsInternet of things
Internet of things
 
Internet of things - The Present & The Future
Internet of things - The Present & The FutureInternet of things - The Present & The Future
Internet of things - The Present & The Future
 
Tech Talk IOT
Tech Talk IOTTech Talk IOT
Tech Talk IOT
 
Taller IoT en la Actualidad
Taller IoT en la ActualidadTaller IoT en la Actualidad
Taller IoT en la Actualidad
 
Intel IoT Edge Computing 在 AI 領域的應用與商機
Intel IoT Edge Computing 在 AI 領域的應用與商機Intel IoT Edge Computing 在 AI 領域的應用與商機
Intel IoT Edge Computing 在 AI 領域的應用與商機
 
arduino 320126512170.pptx
arduino 320126512170.pptxarduino 320126512170.pptx
arduino 320126512170.pptx
 
Global Azure Bootcamp 2016 - Real-world Internet of Things Backend with Azure...
Global Azure Bootcamp 2016 - Real-world Internet of Things Backend with Azure...Global Azure Bootcamp 2016 - Real-world Internet of Things Backend with Azure...
Global Azure Bootcamp 2016 - Real-world Internet of Things Backend with Azure...
 
Bare metal Javascript & GPIO programming in Linux
Bare metal Javascript & GPIO programming in LinuxBare metal Javascript & GPIO programming in Linux
Bare metal Javascript & GPIO programming in Linux
 
How To Electrocute Yourself using the Internet
How To Electrocute Yourself using the InternetHow To Electrocute Yourself using the Internet
How To Electrocute Yourself using the Internet
 
Android meets Arduino
Android meets ArduinoAndroid meets Arduino
Android meets Arduino
 
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
Getting Started with the Internet of Things  - Allianz Hackrisk Hackathon 29/...Getting Started with the Internet of Things  - Allianz Hackrisk Hackathon 29/...
Getting Started with the Internet of Things - Allianz Hackrisk Hackathon 29/...
 
ARUDINO UNO and RasberryPi with Python
 ARUDINO UNO and RasberryPi with Python ARUDINO UNO and RasberryPi with Python
ARUDINO UNO and RasberryPi with Python
 
Interoperability in Internet of Things (IOT)
Interoperability in Internet of Things (IOT)Interoperability in Internet of Things (IOT)
Interoperability in Internet of Things (IOT)
 
RAHUL NASKAR IOT.ppt
RAHUL NASKAR IOT.pptRAHUL NASKAR IOT.ppt
RAHUL NASKAR IOT.ppt
 
Road to Republic of IoT - IoT Technologies & Machine Learning
Road to Republic of IoT - IoT Technologies & Machine LearningRoad to Republic of IoT - IoT Technologies & Machine Learning
Road to Republic of IoT - IoT Technologies & Machine Learning
 
Introduction to iot and arduino uno r3
Introduction to iot and arduino uno r3Introduction to iot and arduino uno r3
Introduction to iot and arduino uno r3
 
Internet of things (IoT) with Azure
Internet of things (IoT) with AzureInternet of things (IoT) with Azure
Internet of things (IoT) with Azure
 
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
 
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
 

More from stable|kernel

Mobile Development For Arduino 201 - ConnectTech
Mobile Development For Arduino 201 - ConnectTechMobile Development For Arduino 201 - ConnectTech
Mobile Development For Arduino 201 - ConnectTechstable|kernel
 
Striking a Balance With UI Tests - ConnectTech
Striking a Balance With UI Tests - ConnectTechStriking a Balance With UI Tests - ConnectTech
Striking a Balance With UI Tests - ConnectTechstable|kernel
 
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor ExtensionsConnect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensionsstable|kernel
 
Connect.Tech- Aqueduct: A server-side framework in Dart
Connect.Tech- Aqueduct: A server-side framework in DartConnect.Tech- Aqueduct: A server-side framework in Dart
Connect.Tech- Aqueduct: A server-side framework in Dartstable|kernel
 
Connect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCIConnect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCIstable|kernel
 
Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Managementstable|kernel
 

More from stable|kernel (6)

Mobile Development For Arduino 201 - ConnectTech
Mobile Development For Arduino 201 - ConnectTechMobile Development For Arduino 201 - ConnectTech
Mobile Development For Arduino 201 - ConnectTech
 
Striking a Balance With UI Tests - ConnectTech
Striking a Balance With UI Tests - ConnectTechStriking a Balance With UI Tests - ConnectTech
Striking a Balance With UI Tests - ConnectTech
 
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor ExtensionsConnect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
Connect.Tech- Enhancing Your Workflow With Xcode Source Editor Extensions
 
Connect.Tech- Aqueduct: A server-side framework in Dart
Connect.Tech- Aqueduct: A server-side framework in DartConnect.Tech- Aqueduct: A server-side framework in Dart
Connect.Tech- Aqueduct: A server-side framework in Dart
 
Connect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCIConnect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCI
 
Connect.Tech- Swift Memory Management
Connect.Tech- Swift Memory ManagementConnect.Tech- Swift Memory Management
Connect.Tech- Swift Memory Management
 

Recently uploaded

KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 

Recently uploaded (20)

KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 

Connect.Tech- Android Development For Arduino 101

  • 1. Android Development For Arduino 101 By: Bryan Jones Richardson Software Engineer stable|kernel
 bryan.richardson@stablekernel.com 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.
  • 7.
  • 8.
  • 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 sarah.woodward@stablekernel.com Bryan Jones Richardson Software Engineer bryan.richardson@stablekernel.cm blog.stablekernel.com