     Serial.println("I'm alive");
     keepAliveNextCheck = now + 2000;
   }
-  val = (exp(sin(millis()/2000.0*PI)) - 0.36787944)*108.0;
-  switch(counter % 3) {
-    case 0:
-      analogWrite(RED_PIN, val);
-      break;
-    case 1:
-      analogWrite(YELLOW_PIN, val);
-      break;
-    case 2:
-      analogWrite(GREEN_PIN, val);
-      break;
-  }
-
-  if(val == 0) {
-    //++counter;
-    //delay(1);
+  if(LEDBreathingState) {
+    updateLED();
   }
 }
 

unsigned long servoDelay = 2;

unsigned long keepAliveNextCheck = 0;
unsigned long redLEDNextCheck = 0;
unsigned long yellowLEDNextCheck = 0;
unsigned long greenLEDNextCheck = 0;

void setup() {
  Serial.begin(9600);

      tide(UP, val);
    } else if (command == "tidedown") {
      tide(DOWN, val);
    } else if (command == "breathingstate") {
      LEDBreathingState = val;
    } else if (command == "red") {
      LEDBreathingState &= ~RED_MASK;
      analogWrite(RED_PIN, val);
    } else if (command == "yellow") {
      LEDBreathingState &= ~YELLOW_MASK;
      analogWrite(YELLOW_PIN, val);
    } else if (command == "green") {
      LEDBreathingState &= ~GREEN_MASK;
      analogWrite(GREEN_PIN, val);
    } else {
      Serial.println("Command not understood!");
    }
