reads the sensor data

Dependencies:   MAG3110 MMA8451Q SLCD TSI mbed-src

Fork of KL46Z by JP PANG

Files at this revision

API Documentation at this revision

Comitter:
jppang
Date:
Mon Oct 14 14:57:22 2013 +0000
Child:
1:e62070cc6725
Child:
3:96fe777bad5a
Commit message:
Tried out the FRDM-KL46Z

Changed in this revision

MAG3110.lib Show annotated file Show diff for this revision Revisions of this file
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.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAG3110.lib	Mon Oct 14 14:57:22 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/jppang/code/MAG3110/#9644c7d596a1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Mon Oct 14 14:57:22 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/JoKer/code/MMA8451Q/#2d14600116fc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSI.lib	Mon Oct 14 14:57:22 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/vsluiter/code/TSI/#4dc2f5a3a731
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 14 14:57:22 2013 +0000
@@ -0,0 +1,59 @@
+//KL46Z try out
+#include "mbed.h"
+#include "TSISensor.h"
+#include "MMA8451Q.h"
+#include "MAG3110.h"
+#include <cstdlib>
+#include <iostream>
+
+Serial pc(USBTX, USBRX);
+
+TSISensor tsi;
+MMA8451Q acc51(PTE25, PTE24, 0x1D<<1);
+MAG3110 mag(PTE25, PTE24, 0x0E<<1);
+
+PwmOut rled(PTE29);
+PwmOut gled(PTD5);
+AnalogIn lightSensor(PTE22);
+DigitalIn SW1(PTC3);
+DigitalIn SW3(PTC12);
+//AnalogOut lcd03(PTB23);
+//PwmOut lcd07(PTB7);
+
+
+int main()
+{
+    using namespace std;
+    
+    float onTime = 1.0;
+    float offTime = 0.0;
+    float holdTime = 1.0;
+    bool on = true;
+    bool off = false;
+    int magX = 0, magY = 0, magZ = 0;
+    //lcd03.write(0.33);
+    //lcd07.write(0.25);
+    //lcd07.period_ms(10);
+        
+    while(true) {
+                
+        rled = onTime - abs(acc51.getAccX());
+        gled = onTime - abs(acc51.getAccY());
+        mag.getValues(&magX, &magY, &magZ);
+        
+        cout << "MMA8451: " << acc51.getAccX() << "\t" << acc51.getAccY() << "\t" << acc51.getAccZ() << "\n\r" << endl;
+        cout << "MAG3110: " << magX << "\t" << magY << "\t" << magZ << "\n\r" << endl;
+        cout << "MAG3110: " << mag.getHeading() << "\n\r" << endl;
+        wait(holdTime);
+        
+        rled = tsi.readPercentage();
+        gled = tsi.readPercentage();
+        
+        cout << "Touch: " << tsi.readPercentage() << "\n\r" << endl;
+        cout << "SW1: " << SW1 << "\n\r" << endl;
+        cout << "SW3: " << SW3 << "\n\r" << endl;
+        cout << "Light Sensor: " << lightSensor << "\n\r" << endl;
+        wait(holdTime);
+    }
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.lib	Mon Oct 14 14:57:22 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/#a9913a65894f