![](/media/cache/profiles/90a82bf94b4c5981e7e68ff425e519f3.50x50_q85.jpg)
Buletooth module(RX-42XVP) sample program
Buletoothモジュール(RN-42XVP)の青mbed(LPC1768)での動作確認
<概要>
トランジスタ技術2014年3月号 3章のBuletoothモジュール(RN-42XVP)とLPC810を使った作例で、LPC810を青mbed(LPC1768)に変更して、配線とmbedプログラムを簡素化して動作確認をしやすくしました。
動作例動画:
<機材準備>
- 配線 Buletoothモジュールへの電源供給はmbedから行います。またシリアル通信線2本をmbedに接続します。
RN-42XVP | mbed(LPC1768) |
---|---|
Pin1(Vcc) | VOUT(3.3V) |
Pin2(DOUT) | p14(rx) |
Pin3(DIN) | p13(tx) |
Pin10 | GND(0V) |
- Androidアプリ
AndroidアプリはCQ出版社のwebからダウンロードします。
http://toragi.cqpub.co.jp/tabid/707/Default.aspx
パソコンからandroidへのインストールはトランジスタ技術の記事を参照してください。
- 青mbed(LPC1768)のプログラム
Mbedのwebからダウンロードしてください。
Import programRN-42XVPsample
Buletooth module(RX-42XVP) sample program
<動作>
Androidアプリはテンキー(0~9)と”LED ON/OFF”のボタンがあり、これらのボタンを押すとアスキーコードの’0’~’9’,’+’,’-‘が送信されます。これを青mbedで受信して、mbed上の4つのLEDを制御します。また受信したデータをmbedのUSB-Serialで外部に送信します。パソコンでターミナルソフト(TeraTarmなど)で確認できます。
以上
Revision 0:66a02c06ec33, committed 2014-02-23
- Comitter:
- suupen
- Date:
- Sun Feb 23 00:24:55 2014 +0000
- Commit message:
- Buletooth module(RN-42XVP)sample program
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 66a02c06ec33 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Feb 23 00:24:55 2014 +0000 @@ -0,0 +1,54 @@ +/** + Transistor Gijutsu 2014nen 3gatugo page.64 3syo + Buletooth ban + LPC810 wo LPC1768 ni henko sita sample program + + +RN-42XVP LPC1768 +------------------- +Pin1 VOUT +Pin2 p14(rx) +Pin3 p13(tx) +Pin10 GND + +*/ +#include "mbed.h" + +BusOut myleds(LED1, LED2, LED3, LED4); + +Serial pc(USBTX, USBRX); // (tx, rx) +Serial xbee(p13, p14); // (tx,rx) RN-42XVP tuusinyo serial + +int main() +{ + uint8_t rawData; + uint8_t newData; + + xbee.baud(115200); + + while(1) { + + if(1 == xbee.readable()) { + rawData = xbee.getc(); + + pc.printf("rawData = %02x\n",rawData); + + if(rawData != 0x00) { + if(rawData == '+') { + newData = 0x0f; + } else if(rawData == '-') { + newData = 0x00; + } else if(rawData == '0') { + newData = 0x0a; + } else { + newData = rawData - '0'; + } + + myleds = newData; + + + } + + } + } +}
diff -r 000000000000 -r 66a02c06ec33 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Feb 23 00:24:55 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1 \ No newline at end of file