![Page 1: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/1.jpg)
BLUETOOTHで動かす!ANDROIDミニ四駆&ANDROIDロボットのつくりかた
KLab/karakuriたけいひでゆき
2010/06/26Android Bazaar and Conference 2010 Spring
![Page 2: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/2.jpg)
AGENDA
• 自己紹介 & karakuriの紹介
• Android時代のミニ四駆
• Androidロボット「もなか」
•共通するシステム構成はこれだ!
• Android1.6でのBluetoothの使い方
• Bluetooth-UART変換モジュールの使い方
![Page 3: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/3.jpg)
自己紹介
• たけいひでゆき @hideyuki_• KLab株式会社• karakuri• 昼:仕事•夜:はんだテラピー•ミニ四駆開発者?!
![Page 4: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/4.jpg)
![Page 5: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/5.jpg)
からんで × くりだす = どひゃー!たけい
回路&ソフト
うえじま
デザイン&映像
まつむら
ハード設計製作
![Page 6: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/6.jpg)
![Page 7: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/7.jpg)
![Page 8: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/8.jpg)
![Page 9: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/9.jpg)
![Page 10: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/10.jpg)
![Page 11: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/11.jpg)
![Page 12: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/12.jpg)
![Page 13: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/13.jpg)
なかみの説明(ANDROID編)
![Page 14: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/14.jpg)
ANDROID携帯との接続
Bluetooth(SPP)
• Android1.6ではBluetooth使えないんじゃ?• esmasuiさん作「backport-android-bluetooth」を使えばBluetoothが使えます!(多謝!)
![Page 15: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/15.jpg)
BLUETOOTHをどう扱うか
• Android Developerのサイトに詳しいことが!
• http://developer.android.com/guide/topics/wireless/bluetooth.html
![Page 16: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/16.jpg)
使い方• BluetoothAdapterを取得&有効化• Bluetoothデバイスのスキャン&接続• BluetoothSocketを開く• mmSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
• データを送る•mmInStream = socket.getInputStream();• bytes = mmInStream.read(buffer);• mmOutStream = socket.getOutputStream();• mmOutStream.write(bytes);
![Page 17: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/17.jpg)
なかみの説明(デバイス編)
![Page 18: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/18.jpg)
ミニ四駆のシステム構成
AVRTINY2313
Bluetoothモジュール
レブチューンモータPRO
ドライバNDS9936
赤LED * 5
バッテリeneloop1.2V * 2
DC/DCコンバータ2.7Vフォト
インタラプタ
PWM
UART
PWM
![Page 19: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/19.jpg)
MONAKAのシステム構成
AVRMEGA128
Bluetoothモジュール
フルカラーLED * 2
LEDドライバTD62004
サーボ*3VS-S020
バッテリ/ACアダプタ7.4V
MP3プレーヤGPS, 加速度センサ
PWM
UART
PWM
この2つが重要!
![Page 20: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/20.jpg)
Bluetooth(SPP) BTモジュール
マイコン
ペリフェラル
![Page 21: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/21.jpg)
BLUETOOTH-UARTモジュールBT-MOD100R
•CLASS2対応•通信距離は約30m• SPP(Serial Port Profile)搭載•技適認証取得済み!• RS232Cの無線化を完全 エミュレートする機能搭載•AVRとはUARTで繋ぐ•非同期式シリアル通信 (UART)
![Page 22: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/22.jpg)
![Page 23: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/23.jpg)
3.0V
マイコン
VccGND
TxRx UART
サーボLED
加速度センサなど
BTモジュールの最大定格3.3Vを超えるとモジュールが壊れます!
![Page 24: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/24.jpg)
送信コマンド例
• ヘッダ - コマンド - [サーボの角度などの情報]・・・•例:0x82FF0145 (左手のサーボ位置を0x145に)
#define CMD_HEADER 0x82#define CMD_LEFT 0xFF#define CMD_RIGHT 0xFE#define CMD_HEAD 0xFD#define CMD_LEDR 0xFC#define CMD_LEDG 0xFB#define CMD_LEDB 0xFA
![Page 25: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s](https://reader031.vdocuments.net/reader031/viewer/2022020207/557d80b7d8b42ad67d8b4db7/html5/thumbnails/25.jpg)
まとめ
• ハードもできるともっとおもしろいことができるぞ!• 2階のBazzarブースで展示しています!•参考資料• backport-android-bluetooth http://bit.ly/8Zvc4b • BT-MOD100R http://bit.ly/9PKxf4