Bluetooth serial communication with Bluetooth Shield from Seeed Studio

Dependencies:   BluetoothSerial mbed

Fork of Bluetooth_demo by Yihui Xiong

Files at this revision

API Documentation at this revision

Comitter:
yihui
Date:
Thu Feb 20 03:31:49 2014 +0000
Commit message:
initial

Changed in this revision

BluetoothSerial.lib Show annotated file Show diff for this revision Revisions of this file
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 e0f48c28e5c1 BluetoothSerial.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BluetoothSerial.lib	Thu Feb 20 03:31:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/yihui/code/BluetoothSerial/#f56002898ee8
diff -r 000000000000 -r e0f48c28e5c1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 20 03:31:49 2014 +0000
@@ -0,0 +1,38 @@
+
+
+#include "mbed.h"
+#include "BluetoothSerial.h"
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+BluetoothSerial bluetooth(P0_19, P0_18);
+
+int main()
+{ 
+    int count = 0;
+
+    bluetooth.setup();
+#if 1
+    bluetooth.slave("btslave8seeed");  // default PIN code: 0000
+    wait(2);
+    bluetooth.connect();
+#else
+    bluetooth.master("btmaster8seeed");
+    wait(2);
+    bluetooth.connect("btslave8seeed");
+#endif
+   
+    while (1) {
+        if (bluetooth.readable()) {
+            led2 = !led2;
+        }
+        
+        count++;
+        if (count >= 1000000) {
+            led1 = !led1;
+            count = 0;
+        }
+    }
+    
+}
+
diff -r 000000000000 -r e0f48c28e5c1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 20 03:31:49 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file