 // 53 on the Mega) must be left as an output or the SD
 // library functions will not work.
 const int CSpin = 10;
-String dataString = ""; // holds the data to be written to the SD card
+String dataString; // holds the data to be written to the SD card
 float sensorReading1 = 0.00; // value read from your first sensor
 float sensorReading2 = 0.00; // value read from your second sensor
-float sensorReading3 = 0.00; // value read from your third sensor
-float sensorReading4 = 0.00;
-float sensorReading5 = 0.00;
-float sensorReading6 = 0.00;
-float sensorReading7 = 0.00;
-float sensorReading8 = 0.00;
+float gyroX = 0.00; // value read from your third sensor
+float gyroY = 0.00;
+float gyroZ = 0.00;
+float accelX = 0.00;
+float accelY = 0.00;
+float accelZ = 0.00;
 
 #define PRINT_SPEED 250 // 250 ms between prints
 static unsigned long lastPrint = 0; // Keep track of print time

#include "HallEffect.h"
#include "IMU.h"
#include "SDHelper.h"

/* hallEffect leftHall, rightHall; */
potentiometer shockLeftPot, shockRightPot;


    if ((lastPrint + PRINT_SPEED) < millis())
    {
        gyroX = imu.calcGyro(imu.gx);
        gyroY = imu.calcGyro(imu.gy);
        gyroZ = imu.calcGyro(imu.gz);
        //accel readings
        accelX = imu.calcAccel(imu.ax);
        accelY = imu.calcAccel(imu.ay);
        accelZ = imu.calcAccel(imu.az);
        lastPrint = millis(); // Update lastPrint time
    }
    // build the data string
    
    //dataString = String(sensorReading1) + ",";
    //dataString += String(sensorReading2) + ",";
    dataString = String(gyroX) + ",";
    dataString += String(gyroY) + ",";
    dataString += String(gyroZ) + ",";
    dataString += String(accelX) + ",";
    dataString += String(accelY) + ",";    
    dataString += String(accelZ) + ","; // for IMU
    
    dataString += String(shockLeftPos)+ ",";
    dataString += String(shockRightPos)  + ",";
    dataString += String(brakePressureFrontValue) + ",";
    

    // Debug print statements
    Serial.print( "Gyro X: " );
    Serial.println(gyroX);
    Serial.print( "Gyro Y: " );
    Serial.println(gyroY);
    Serial.print( "Gyro Z: " );
    Serial.println(gyroZ);
    Serial.print( "Accel X: " );
    Serial.println(accelX);
    Serial.print( "Accel Y: " );
    Serial.println(accelY);
    Serial.print( "Accel Z: " );
    Serial.println(accelZ);
    
    //Serial.println ( brakePressureFrontValue );
    // convert to CSV
    saveData(dataString); // save to SD card
}
