2012年6月13日 星期三

Android + Arduino 合體 使用mega 2560 b/d

Android 3.1 ( 2.3.4 ) 整合了開源的 Arduino  .以下教學


ADK  (Android Open Accessory Development Kit )


在Android 3.1平台(也 backport到Android 2.3.4)推出Android開放套件的支持,它允許外部
USB硬件(一個Android USB附件)可以透過在一個特殊的“套件”模式的啟動連接設備進行交互溝通連接。當機器人供電的供電設備配套模式,連接配件的行為作為USB主機和USB設備的Andr​​oid供電設備的行為。

官方下載套件  :

adk software package




CapSense  library   (sense human capacitance )
v.04



Arduino

是一個開發開放原始碼--有著設計靈活,易於使用的硬件和軟件為基礎的電子原型平台。
可以創建互動的物體或環境感興趣的人,Arduino的可以感知環境,通過接收來自各種傳感器
的輸入,並可以控制燈光,馬達,和其他驅動器及其周圍地區的影響。主板上的微控制器進行開發。Arduino的項目,可單獨或他們可以與軟件的計算機上運行。


官方下載套件  :

arduino  v1.01



Google ADK 參考設計的 Arduino 相容平台
















開始結合說明

1.安裝  Arduino software and  libraries

On Windows:
Copy the arduino_libs/AndroidAccessory and arduino_libs/USB_Host_Shield directories (the complete directories, not just the files within) to the <arduino_installation_root>/libraries/ directory.
Copy the extracted CapSense/ library directory and its contents to the <arduino_installation_root>/libraries/ directory.

You should now have three new directories in the Arduino libraries/ directory: AndroidAccessory, USB_Host_Shield, and CapSense.




2.  Installing the firmware to the ADK board

To install the firmware to the ADK board:

Connect the ADK board to your computer using the micro-USB port, which allows two-way communication and provides power to the ADK board.
Launch the Arduino IDE.
Click Tools > Board > Arduino Mega 2560 to specify the ADK board's type.
Select the appropriate USB port:
On Windows: click Tools > Serial Port > COM# to specify the port of communication. The COM port number varies depending on your computer. COM1 is usually reserved for serial port connections. You most likely want COM2 or COM3.
To open the Demokit sketch (firmware code), click File > Examples > AndroidAccessory > demokit.
Click Sketch > Verify/Compile to ensure that the sketch has no errors.
Select File > Upload. When Arduino outputs Done uploading., the board is ready to communicate with your Android-powered device.


3.執行app 應用程式


 in Eclipse 安裝與執行:

Install the Google APIs API Level 10 add-on library, for 2.3.4 devices
 all you need is API Level 12, for about Android 3.1 or newer devices

Click File > New > Project..., then select Android > Android Project
In the Project name: field, type DemoKit.
Choose Create project from existing source, click Browse, select the app directory, click Open to close that dialog and then click Finish.
For Build Target, select Google APIs (Platform 2.3.3, API Level 10).
Note: Even though the add-on is labeled as 2.3.3, the newest Google API add-on library for API level 10 adds USB Open Accessory API support for 2.3.4 devices.
Click Finish.

Install the application to your device.

連結 ADK board (USB-A) to your Android-powered device (micro-USB).
你現在你以透過 驅動 moving the color LEDor servo sliders
 觀察在 ADK shield, 你可以按紐或操縱桿去看看螢幕上面的變化.














沒有留言:

張貼留言