Playing around with accelerometer and magnetometer on mbed KL46Z

Dependencies:   MAG3110 MMA8451Q PinDetect mbed TSI

Files at this revision

API Documentation at this revision

Comitter:
mohammmo
Date:
Thu Feb 06 07:39:34 2014 +0000
Parent:
8:b87b93a62a6a
Commit message:
Changed printData to use puts, changed baud rate = 115200

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Feb 06 06:10:19 2014 +0000
+++ b/main.cpp	Thu Feb 06 07:39:34 2014 +0000
@@ -40,6 +40,7 @@
 char buffer[bufferSize];
 int index = 0;
 bool received = false;
+char tx_buffer[80];
 
 // Declare Accelerometer pins and I2C address
 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS, 0, 0);
@@ -63,7 +64,7 @@
 void init()
 {
     // Attach timerAcc
-    //pc.baud(9600);
+    pc.baud(115200);
     timerAcc.attach(&accTime, accRate);
     timerMag.attach(&magTime, magRate);
     timerLight.attach(&lightTime, lightRate);
@@ -93,7 +94,8 @@
 
 void printData()
 {
-    pc.printf("/%f/%f/%f/%d/%d/%d/%f/%f/%f/%f/%f/%f/\r\n", xAcc, yAcc, zAcc, xMag, yMag, zMag, xLight, xTouch, accRate, magRate, lightRate, touchRate);
+    sprintf(tx_buffer,"/%f/%f/%f/%d/%d/%d/%f/%f/%f/%f/%f/%f/\r\n", xAcc, yAcc, zAcc, xMag, yMag, zMag, xLight, xTouch, accRate, magRate, lightRate, touchRate);
+    pc.puts(tx_buffer);
 }  
 
 void receiveHandler()