Slightly modified version (to work with processing GUI)

Dependencies:   ITG3200 mbed

Fork of 6DoF_IMU_readvalue by Ryo Nakabayashi

Revision:
1:c85175226571
Parent:
0:cda6d9f5a43c
Child:
2:39468ef68358
diff -r cda6d9f5a43c -r c85175226571 main.cpp
--- a/main.cpp	Mon Nov 26 05:34:56 2012 +0000
+++ b/main.cpp	Tue Feb 12 02:31:21 2013 +0000
@@ -2,15 +2,17 @@
 #include "ADXL345_I2C.h"
 
 Serial pc(USBTX, USBRX);
-ITG3200 gyro(p9, p10);
-ADXL345_I2C accel(p9, p10);
+ITG3200 gyro(p28, p27);
+ADXL345_I2C accel(p28, p27);
 
 int main() {
+    char str[512];
     gyro.setWhoAmI(0x68);
     pc.printf("Now starting 6-degrees-of-freedom (ITG-3200 ADXL345) test...\n");
     pc.printf("Accelerometer Device ID is: 0x%02x\n", accel.getDeviceID());
-    pc.printf("Gyro Devide ID is: 0x02x\n", gyro.getWhoAmI());
-    
+    pc.printf("Gyro Devide ID is: 0x%02x\n", gyro.getWhoAmI());
+     
+     
     int accel_read[3] = {0, 0, 0};
     
     // Accel setup
@@ -42,14 +44,21 @@
     // Gyro setup   
     gyro.setLpBandwidth(LPFBW_42HZ);
 
-    while (1) {
+    while (1)
+    {
         wait(0.1);
         
         accel.getOutput(accel_read);
         
-        pc.printf("Gyro[%5i, %5i, %5i]   Accel[%4i, %4i, %4i]\n", 
+        sprintf(str, "%i,%i,%i,%i,%i,%i,%i\n", (int16_t)accel_read[0], (int16_t)accel_read[1], (int16_t)accel_read[2],
+                                                     gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ(), (int16_t)gyro.getTemperature());  
+        pc.printf(str);
+        
+        /*
+        pc.printf("Gyro[%5i, %5i, %5i]   Accel[%4i, %4i, %4i]\n\t", 
                             gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ(),
                             (int16_t)accel_read[0], (int16_t)accel_read[1], (int16_t)accel_read[2]);
+        */
     }
     
 }