25
BLUETOOTHで動かす! ANDROIDミニ四駆& ANDROIDロボットの つくりかた KLab/karakuri たけいひでゆき 2010/06/26 AndroidBazaarandConference2010Spring

Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

Embed Size (px)

DESCRIPTION

ミニ四駆やAndroidロボットをAndroid携帯からBluetooth経由で操作する方法をご紹介いたします!! ABC2010Spring → http://www.android-group.jp/index.php?%A5%A4%A5%D9%A5%F3%A5%C8%2FAndroid%20Bazaar%20and%20Conference%202010%20Spring karakuri → http://www.ka-ra-ku-ri.net/

Citation preview

Page 2: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

AGENDA

• 自己紹介 & karakuriの紹介

• Android時代のミニ四駆

• Androidロボット「もなか」

•共通するシステム構成はこれだ!

• Android1.6でのBluetoothの使い方

• Bluetooth-UART変換モジュールの使い方

Page 3: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

自己紹介

• たけいひでゆき @hideyuki_• KLab株式会社• karakuri• 昼:仕事•夜:はんだテラピー•ミニ四駆開発者?!

Page 4: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s
Page 5: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

からんで × くりだす = どひゃー!たけい

回路&ソフト

うえじま

デザイン&映像

まつむら

ハード設計製作

Page 6: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s
Page 7: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s
Page 8: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s
Page 9: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s
Page 10: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s
Page 11: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s
Page 12: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s
Page 13: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

なかみの説明(ANDROID編)

Page 14: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

ANDROID携帯との接続

Bluetooth(SPP)

• Android1.6ではBluetooth使えないんじゃ?• esmasuiさん作「backport-android-bluetooth」を使えばBluetoothが使えます!(多謝!)

Page 16: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

使い方• 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

なかみの説明(デバイス編)

Page 18: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

ミニ四駆のシステム構成

AVRTINY2313

Bluetoothモジュール

レブチューンモータPRO

ドライバNDS9936

赤LED * 5

バッテリeneloop1.2V * 2

DC/DCコンバータ2.7Vフォト

インタラプタ

PWM

UART

PWM

Page 19: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

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

Bluetooth(SPP) BTモジュール

マイコン

ペリフェラル

Page 21: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

BLUETOOTH-UARTモジュールBT-MOD100R

•CLASS2対応•通信距離は約30m• SPP(Serial Port Profile)搭載•技適認証取得済み!• RS232Cの無線化を完全 エミュレートする機能搭載•AVRとはUARTで繋ぐ•非同期式シリアル通信 (UART)

Page 22: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s
Page 23: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

3.0V

マイコン

VccGND

TxRx UART

サーボLED

加速度センサなど

BTモジュールの最大定格3.3Vを超えるとモジュールが壊れます!

Page 24: Bluetoothで動かす!Androidミニ四駆&Androidロボットの つくりかた - ABC2010Spring #abc2010s

送信コマンド例

• ヘッダ - コマンド - [サーボの角度などの情報]・・・•例: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

まとめ

• ハードもできるともっとおもしろいことができるぞ!• 2階のBazzarブースで展示しています!•参考資料• backport-android-bluetooth http://bit.ly/8Zvc4b • BT-MOD100R http://bit.ly/9PKxf4