         
       //Create message for serial port
       sprintf(msg, "%d,%d.%03d,%d,%s,%s,%s",
-      totalHour,totalSec,
-      cpmTimeMSec,
-      signCount,
-      cpmBuff,
-      uSvBuff,
-      uSvdBuff
+        totalHour,totalSec,
+        cpmTimeMSec,
+        signCount,
+        cpmBuff,
+        uSvBuff,
+        uSvdBuff
         );
         
       //Send message to serial port

          cpmIndex = 0;
        }
        
        if(radiationWatch._cpmHistory[cpmIndex] > 0)
        {
          cpm -= radiationWatch._cpmHistory[cpmIndex];
        }
        radiationWatch._cpmHistory[cpmIndex]=0;
      }
      
      //Store count log
      radiationWatch._cpmHistory[cpmIndex] += signCount;
      //Add number of counts
      cpm += signCount;
      
      //Get ready time for 10000 loops
      cpmTimeMSec += abs(currTime - prevTime);
      //Transform from msec. to sec. (to prevent overflow)
      if(cpmTimeMSec >= 1000)
      {

    int signPin();
    int noisePin();
  
  private:
    static const unsigned int kHistoryCount = 200;

    double _cpmHistory[kHistoryCount]; //History of count rates
    
    int _prevTime;

    int _signPin;   //Radiation Pulse (Yellow)
    int _noisePin;  //Vibration Noise Pulse (White)

    static const double alpha=53.032; // cpm = uSv x alpha
    
    int index; //Number of loops
    char msg[256]; //Message buffer for serial output
    
    int signCount;  //Counter for Radiation Pulse
    int noiseCount;  //Counter for Noise Pulse
    
    int sON;//Lock flag for Radiation Pulse
    int nON;//Lock flag for Noise Puls
    
    double cpm; //Count rate [cpm] of current
    int cpmIndex;//Position of current count rate on cpmHistory[]
    int cpmIndexPrev;//Flag to prevent duplicative counting
    
    //Timing Settings for Loop Interval
    int currTime; 
    
    int totalSec; //Elapsed time of measurement [sec]
    int totalHour; //Elapsed time of measurement [hour]
    
    //Time settings for CPM calcuaration
    int cpmTimeMSec;
    int cpmTimeSec;
    int cpmTimeMin;
    
    //String buffers of float values for serial output
    char cpmBuff[20];
    char uSvBuff[20];
    char uSvdBuff[20];
};

RadiationWatch::RadiationWatch(int signPin, int noisePin) : _signPin(signPin), _noisePin(noisePin)
{
  _prevTime = 0;
  index = 0;
  
  msg[0] = 0;
  
  signCount=0;
  noiseCount=0;
  
  sON=0;
  nON=0;
  
  cpm = 0;
  cpmIndex = 0;
  cpmIndexPrev = 0;
  
  currTime = 0;
  
  totalSec = 0;
  totalHour = 0;
  
  cpmTimeMSec = 0;
  cpmTimeSec = 0;
  cpmTimeMin = 0;
}

void RadiationWatch::setup()
