トランジスタ技術2015年6月号mbedラジコン・カーp184 リスト4 Bluetoothモジュールのmbedメイン・プログラム
Dependencies: mbed
Revision 0:e423d98fecae, committed 2015-06-01
- Comitter:
- YoshihitoShimada
- Date:
- Mon Jun 01 02:40:04 2015 +0000
- Commit message:
- Bluetooth test 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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jun 01 02:40:04 2015 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" +Serial bluetooth(P0_19, P0_18); //tx, rx +DigitalOut Light(P0_16); + +int main() { + bluetooth.baud(115200); + int32_t i; + uint8_t buf; + char moji[64]; + + Light=0; + + while (1) { + if(bluetooth.readable()) { + i=0; + do { + buf=bluetooth.getc(); + moji[i++]=buf; + } while(buf!='\0'); + buf=moji[0]; + } + switch (buf){ + case '+': //Light On + Light=1; + break; + case '-': //Light Off + Light=0; + break; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jun 01 02:40:04 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file