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
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/
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. 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.
11. USB on Android
Host Mode
Power
Data Transfer
Accessory Mode
Power
Data Transfer
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. 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. Design and Create the Hardware
•
Use Fritzing to design your
breadboard, schematic diagram
and bill of materials.
•
Get it from http://fritzing.org/
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. 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" />