Smartphone++

3,256 views

Published on

slides for GDG Kota Kinabalu Devfest 2013

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,256
On SlideShare
0
From Embeds
0
Number of Embeds
2,281
Actions
Shares
0
Downloads
32
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Smartphone++

  1. 1. Smartphone++ Marc Lester S. Tan Mobile Applications Developer, SAP GDG Devfest Kota Kinabalu 2013
  2. 2. Agenda ●  Overview of Arduino ●  Google ADK ●  Uses of ADK and Demo
  3. 3. Overview of Arduino
  4. 4. Overview of Arduino •  Open-source electronics prototyping platform. •  Intended for Artists, Designers and Hobbyists. •  Arduino Programming Language based on Wiring. •  Arduino IDE based on Processing source: http://www.arduino.cc
  5. 5. Overview of Arduino •  Inexpensive •  Cross-platform •  Simple and clear programming environment. •  Open-source software and hardware
  6. 6. Arduino Shields Shields are boards that can be plugged on top of the Arduino PCB extending its capabilities. •  SD Card Shield •  USB Host Shield •  Ethernet Shield source: http://blog.protoneer.co.nz/
  7. 7. Arduino IDE •  Java •  Based on Processing IDE (processing.org) •  Write and upload code to Arduino board
  8. 8. Arduino Sketch •  setup() o  called once o  setup pin modes o  library initialization •  loop() o  called over the over again o  heart of every sketches
  9. 9. Sample Sketch int inputPin = 12; // let pin 12 be our input pin int outputPin = 11; // let pin 11 be our ouput pin void setup(){ pinMode(outputPin, OUTPUT); // setup output pin to be an OUTPUT pinMode(inputPin, INPUT); // setup input pin to be our INPUT } void loop(){ int inputVal = digitalRead(inputPin); digitalWrite(outputPin, inputVal); delay(100); } // write the value of input pin to output // wait for 100ms // before looping again.
  10. 10. Google ADK
  11. 11. USB on Android Host Mode Power Data Transfer Accessory Mode Power Data Transfer
  12. 12. Google ADK ●  Reference implementation for hardware manufacturers and hobbyists. ●  It uses Android Open Accessory Protocol over USB or Bluetooth ●  The hardware is based on Arduino Mega. ●  Two versions: ADK 2011 and ADK 2012 source: http://www.engadget.com/gallery/googles-arduino-based-adk-hands-on-atgoogle-i-o-2011/
  13. 13. Hello, Physical World •  Design and create the hardware or circuit. •  Write the firmware for your Arduino. •  Create an Android application that can talk to your firmware. source: http://www.youtube.com/watch?v=gcP7KwIENGw
  14. 14. Design and Create the Hardware •  Use Fritzing to design your breadboard, schematic diagram and bill of materials. •  Get it from http://fritzing.org/
  15. 15. Write the Firmware if (acc.isConnected()) { int len = acc.read(msg, sizeof(msg), 1); if(len > 0){ Serial.println(len); if(msg[0] == 0x1){ digitalWrite(13, HIGH); }else{ digitalWrite(13, LOW); } } }else{ digitalWrite(13, LOW); }
  16. 16. Create the Android Application ●  USBManager - available since 3.1 but also available for 2.3.4 using Google API 10 ○  ●  Not all devices support accessory mode Android Manifest Requirements: Declare: <uses-feature android:name="android.hardware.usb.accessory" /> If using Add-on: <application….> <uses-library android:name="com.android.future.usb.accessory" />
  17. 17. Create the Android Application Android Manifest Requirements: <activity ...> ... <intent-filter> <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" / > </intent-filter> <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/accessory_filter" /> </activity>
  18. 18. Create the Android Application res/xml/accessory_filter.xml <?xml version="1.0" encoding="utf-8"?> <resources> <usb-accessory manufacturer="Marc Tan" model="Motor Control" version="1.0" /> </resources>
  19. 19. Create the Android Application onCreate()... mUsbManager = UsbManager.getInstance(this); onResume()... UsbAccessory[] accessories = mUsbManager.getAccessoryList(); UsbAccessory accessory = accessories[0]); if (mUsbManager.hasPermission(accessory)) { openAccessory(accessory); }
  20. 20. Create the Android Application protected void openAccessory(UsbAccessory accessory) { fileDescriptor = mUsbManager.openAccessory(accessory); FileDescriptor fd = fileDescriptor.getFileDescriptor(); input = new FileInputStream(fd); output = new FileOutputStream(fd); } onDestroy()... output.write(0); // optional fileDescriptor.close();
  21. 21. Uses of ADK and Demo
  22. 22. Uses of ADK Audio Docking Station
  23. 23. Uses of ADK Exercise Machines
  24. 24. Uses of ADK Weather Stations
  25. 25. Uses of ADK Home Automation
  26. 26. Demo: Sonar
  27. 27. Demo: Motor Control
  28. 28. Demo: Android as USB Host
  29. 29. Resources Android ADK a.android.com Arduino and Electronics, Others arduino.cc tronixstuff.com hackaday.com My Blog and Github marctan.com github.com/mharkus Quadcopter bitcraze.se
  30. 30. Thank you Questions?

×