KL25Z board with HC-06 bluetooth module try out

Dependencies:   MMA8451Q TSI mbed-src

Files at this revision

API Documentation at this revision

Comitter:
jppang
Date:
Sun Feb 09 09:10:34 2014 +0000
Commit message:
KL25Z with HC-06 Bluetooth module try out

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
TSI.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-src.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 5a3e0b8133dc MMA8451Q.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Sun Feb 09 09:10:34 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/JoKer/code/MMA8451Q/#2d14600116fc
diff -r 000000000000 -r 5a3e0b8133dc TSI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Sun Feb 09 09:10:34 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/vsluiter/code/TSI/#4dc2f5a3a731
diff -r 000000000000 -r 5a3e0b8133dc main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Feb 09 09:10:34 2014 +0000
@@ -0,0 +1,53 @@
+#include "mbed.h"
+#include "TSISensor.h"
+#include "MMA8451Q.h"
+#include <cstdlib>
+#include <iostream>
+
+TSISensor tsi;
+MMA8451Q acc(PTE25, PTE24, 0x1D<<1);
+PwmOut rled(LED_RED);
+PwmOut gled(LED_GREEN);
+PwmOut bled(LED_BLUE);
+DigitalOut testPin(PTC7);
+
+Serial bt(PTC4, PTC3);
+
+int main() {
+    using namespace std;
+    
+    float onTime = 1.0;
+//    float offTime = 0.0;
+    float holdTime = 1.0;
+//    bool on = true;
+    bool off = false;
+    char bt_msg[100] = "";
+    
+    
+    while(true) {
+        
+        rled = onTime - abs(acc.getAccX());
+        gled = onTime - abs(acc.getAccY());
+        bled = onTime - abs(acc.getAccZ());
+        testPin = rand() % 2;
+        cout << "MMA8451Q: " << acc.getAccX() << "\t" << acc.getAccY() << "\t" << acc.getAccZ() << "\n\r" << flush << endl; 
+//        bt.printf("this is a bluetooth test\n");
+        wait(holdTime);
+        
+//        if(bt.readable()){
+//            bt.putc(bt.getc());
+//        }
+        if(bt.readable()){
+            bt.scanf("%s", bt_msg, sizeof(bt_msg));
+        }
+        
+        rled = onTime - tsi.readPercentage();
+        gled = onTime - tsi.readPercentage();
+        bled = onTime - tsi.readPercentage();
+        testPin = off;
+        cout << "Touch Sensor: " << tsi.readPercentage() << "\n\r" << flush << endl;
+//        bt.printf("this is also a bluetooth test\n");
+        bt.printf("%s\n", bt_msg);
+        wait(holdTime);
+    }
+}
diff -r 000000000000 -r 5a3e0b8133dc mbed-src.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Sun Feb 09 09:10:34 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-src/#26fc69fd3b6c