 }
 
 void loop() {
-    sendReady();
     receiveData();
-    if (newData) processData();
-    if (alarmState) toggleEnable();
-    /*
-    durationTurn(2000, 60, true, false);
-    delay(1000);
-    durationTurn(2000, 67, true, false);
-    delay(1000);
-    durationTurn(2000, 72, true, false);
-    delay(1000);
-    durationTurn(1500, 60, true, false);
-    delay(500);
-    durationGliss(1500, 60, 72, true, false, 0);
-    delay(1500);
-    durationGliss(6000, 72, 55, true, false, 900);
-    delay(500);
-    durationGliss(6000, 55, 72, true, false, 900);
-    delay(500);
-    doubleGliss(6000, 6000, 55, 67, 60, 500, 500, 500, true, false);
-    delay(500);
-    doubleGliss(707, 707, 60, 72, 71, 50, 50, 50, true, false);
-    delay(1500);
-    */
-}
+    if (newData) {
+        processData();
+        if (alarmState) toggleEnable();
+        sendReady();
+    }
+}

    Serial.begin(38400);
    findSensor(maxPulse);
    defaults();
}

void setAlarm() {
    alarmState = !alarmState;
}

void toggleEnable() {
    digitalWrite(enablePin, HIGH);
    delay(enableDelay);
    digitalWrite(enablePin, LOW);
    while (alarmState) delay(enableDelay);
}

void defaults() {

#define enablePin       5
#define alarmPin        3
#define sensorPin      11
#define ledPin         13
#define idmsbPin       18
#define idlsbPin       19

