 int nON=0;//Lock flag for Noise Puls
 
 double cpm = 0; //Count rate [cpm] of current
-double cpmHistory[200]; //History of count rates
 int cpmIndex=0;//Position of current count rate on cpmHistory[]
 int cpmIndexPrev=0;//Flag to prevent duplicative counting
 
 //Timing Settings for Loop Interval
-int prevTime=0;
 int currTime=0; 
 
 int totalSec=0; //Elapsed time of measurement [sec]

char uSvBuff[20];
char uSvdBuff[20];

void setup()
{
  //Serial setup
  //9600bps
  Serial.begin(9600);
  
  //PIN setting for Radiation Pulse
  pinMode(signPin,INPUT);
  digitalWrite(signPin,HIGH);

  //PIN setting for Noise Pulse
  pinMode(noisePin,INPUT);
  digitalWrite(noisePin,HIGH);

  //CSV-formatting for serial output (substitute , for _)
  Serial.println("hour[h]_sec[s]_count_cpm_uSv/h_uSv/hError");
  
  //Initialize cpmHistory[]
  for(int i=0; i<200;i++ )
  {
    cpmHistory[i]=0;
  }
  
  //Get start time of a loop
  prevTime = millis();
}

void loop()
{
  // Raw data of Radiation Pulse: Not-detected -> High, Detected -> Low
  int sign = digitalRead(signPin);

  // Raw data of Noise Pulse: Not-detected -> Low, Detected -> High
  int noise = digitalRead(noisePin);

  //Radiation Pulse normally keeps low for about 100[usec]
  if(sign==0 && sON==0)

        cpmIndexPrev = totalSec;
        cpmIndex++;
        
        if(cpmIndex >= RadiationWatch::kHistoryCount)
        {
          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;
      
