Bluetooth avanzado

Dependencies:   mbed

Revision:
0:1a819403fbb3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Sep 23 21:03:10 2014 +0000
@@ -0,0 +1,41 @@
+/* 
+    -- TV_bluetooth-Rx-simple --
+    Example using a Bluetooth module. In this case
+    we use the HC-06 model.
+    
+    Pairing code: 1234
+    Baud rate: 9600
+    
+    
+
+*/
+
+
+#include "mbed.h"
+
+DigitalOut myled(LED_GREEN);
+Serial pc(USBTX, USBRX);
+Serial bt(PTE0, PTE1);
+
+
+int main(){
+    int i = 0;
+    pc.printf("Hello World!\n");
+    myled = 1;
+    
+    while (true) {
+        wait(0.5f); // wait a small period of time
+        pc.printf("%d \n", i); // print the value of variable i
+        bt.printf("%d \n", i); // print the value of variable i
+        i++; // increment the variable
+        
+        if (bt.readable()){
+            char c = bt.getc();
+            if (c == 'H' || c == 'h'){
+                myled = 0;
+            }else if (c == 'L' || 'l'){
+                myled = 1;
+            }
+        }
+    }
+}