   scheduler.run();
   delay(5);
 
-}
-
-
-void radEvent() {
+
+}
+
+
+void radEventRise() {
   stopRadSensor();
-  radFlag = 1;
-  radCnt++;
-  startRadSensor();
+  pulseStart = micros();
+  attachInterrupt(radSensor.getPin(), radEventFall, FALLING);
+
+
+}
+
+void radEventFall() {
+  stopRadSensor();
+  if(micros() - pulseStart >= pulseWidth){
+      radFlag = 1;
+      radCnt++;
+  }
+  attachInterrupt(radSensor.getPin(), radEventRise, RISING);
+
 
 }
 
 
 void countFunc() {
+
   countTask.disable();
   stopRadSensor();
   DateTime temp = rtc.now();

RadStorage radStorage(&rFram);

Task countTask(&countFunc, countInterval, 0);


volatile bool radFlag = 0;

  //TODO Power Manegment

  scheduler.addEvent(&countTask);
  scheduler.addEvent(&advertisingTask);
  Bean.enableAdvertising(true);
  delay(5000);

}


void setup() {

  begin();

  blinkBean();

  countTask.enable();
