 
   if(!startRollFlag) { //For roll initialization, cant fins in the direction of current roll
     digitalWrite(homePin, LOW);
+    servoHomePin = false;
     startRollFlag = true;
     if(event.gyro.z > 0) {
       digitalWrite(statePin, HIGH);


void Radio_Transmit(void) {

if(gpsDataFlag && sendFlag) //Send data mode, only if GPS is ready
  {
      gpsDataFlag = false; //Only turn off this flag if Arduino is actively sending GPS data
      sendFlag = false; //Once we send data, wait for data to be received
      
      uint8_t radioPacket[27]; //Buffer of bytes for radio transmission

union{ //Float-to-byte-string converter, needed for GPS data
  float tempFloat;
  byte tempArray[3];
} u;

u.tempFloat = gpsLatitude;
for(int c=0; c<4; c++){
  radioPacket[c] = u.tempArray[c];
}
radioPacket[4] = gpsLatDirect; //N or S
u.tempFloat = gpsLongitude;
for(int c=0; c<4; c++){
  radioPacket[(c+5)] = u.tempArray[c];
}
radioPacket[9] = gpsLonDirect; //E or W
u.tempFloat = gpsAltitude;
for(int c=0; c<4; c++){
  radioPacket[(c+10)] = u.tempArray[c];
}
radioPacket[14] = gpsFix;
radioPacket[15] = gpsFixQuality; //Useful for determining valid/invalid GPS data; if fix or quality are 0 the data isn't reliable

for(int c=0; c<3; c++) {
  radioPacket[c+16] = accelData[c];
  radioPacket[c+19] = gyroData[c];
  radioPacket[c+22] = baroData[c];
}
radioPacket[25] = timeData[0];
radioPacket[26] = timeData[1];

rf95.send((uint8_t *)radioPacket, 27); //Once packet has been constructed, transmit
rf95.waitPacketSent(); //Short, necessary wait for packet transmission to complete
  }



bool startRollFlag = false;
bool endRollFlag = false; //Flags for tracking roll/counter-roll progress
bool finState = false; //Variable for tracking current fin position
bool servoOnFlag;
bool servoHomeFlag; //Two flags to keep track of the other two digital outputs to the servo. ALWAYS CHANGE THESE WHEN CHANGING SERVO OUTPUTS!

float rotationCounter = 0; //Variable for tracking rotation, in revolutions

bool sendFlag = true; //Flag for toggling send/receive mode; makes 2-way communication much easier
bool radioWorkingFlag = true; //Flag to determine if radio initialized properly. If not, then it continues on without comms
bool dataFlag = false; //Since SD saving and radio transmission occur in two different functions, the SD routine uses this flag to tell the radio routine if data is ready for transmission
bool gpsOnFlag = false; //Flag to track whether GPS is currently operating/enabled


void setup() {
