   return value;
 }
 
-void warning(){
-  for(int i=0; i<4; i++){
-    tone(tonePin, 900);
-    delay(500);
-    tone(tonePin, 700);
-    delay(250);
-  }
-  noTone(tonePin);
-}
-
+//void warning(){
+//  for(int i=0; i<4; i++){
+//    tone(tonePin, 900);
+//    delay(500);
+//    tone(tonePin, 700);
+//    delay(250);
+//  }
+//  noTone(tonePin);
+//}
+
+int LEDangles[]={355, 5, 67, 77, 139, 149, 211, 221, 283, 293};
+void setLED(int i, int c[]){
+  for(int j ; j<3; j++){
+    if(c[j]<20){
+      c[j]=0;
+    }
+  }
+  if(i<6){
+    pixelsA.setPixelColor(5-i, pixelsA.Color(c[0], c[1], c[2]));
+    pixelsA.show();
+  }
+  else{
+    pixelsB.setPixelColor(i-6, pixelsA.Color(c[0], c[1], c[2]));
+    pixelsB.show();
+  }
+}
+void setColors(){
+  switch(mode){
+    case 1:{
+      float ratio= 0.7+ 0.3 * sin(((millis()/10)%360)*3.14/180);
+      int tmp[3];
+      for(int i=0; i<3; i++){
+        long a=(endColor[i]-startColor[i])*(millis()-startCurrentMode);
+        if(endColor[i]-startColor[i] <0){
+          a=-abs(a);
+        }
+        color[i]=(a/mode1Duration+startColor[i])%256;
+//        color[i]=startColor[i];
+        color[i]=(int)(color[i]*ratio);
+      }
+
+      if(millis()-startCurrentMode>mode1Duration){
+        changeMode(3);
+      }
+      break;}
+    case 2:
+      if((millis()-startCurrentMode)%1000<600){
+        color[0]=200;
+        color[1]=200;
+        color[2]=200;
+      }
+      else{
+        color[0]=0;
+        color[1]=0;
+        color[2]=0;
+      }
+      //possible drowning
+      break;
+    case 3:
+      //10 minutes have passed
+      if((millis()-startCurrentMode)%2000<1000){
+        color[0]=0;
+        color[1]=200;
+        color[2]=0;
+      }
+      else{
+        color[0]=0;
+        color[1]=0;
+        color[2]=0;
+      }
+      break;
+    case 0:
+        color[0]=0;
+        color[1]=0;
+        color[2]=0;
+        break;
+    default:
+      break;
+  }
+  for(int i=0; i<10; i++){
+    setLED(i, color);
+  }
+}
+
+void changeMode(int i){
+  switch(i){
+    case 1:
+      //normal mode
+      //tracks how much time has passed since start of mode1
+      break;
+    case 2:
+      //warning mode- possible drowning
+      break;
+    case 3:
+      //warning mode- 10minutes have passed
+      break;
+    default:
+      break;
+  }
+  startCurrentMode=millis();
+  mode=i;
+}
+
+//phi is angle of LED
+//theta is edge of current LED lgihting state
+float getRatio(float phi, float theta){
+  float width=100;
+  if(theta-width<0){
+    if(theta<phi || 360+theta-width < phi){
+      return 0.0;
+    }
+    else if(phi<=theta){
+      return (phi-theta+width)/width;
+    }
+    else{
+      return (phi-360.0-theta+width)/width;
+    }
+  }
+  else{
+    return (phi-theta+width)/width;
+  }
+  return 0.0;
+}

      if(reading != buttonState){
        buttonState=reading;
        if(buttonState==LOW){
          isON=!isON;
        }
      }
      }

    while(1);
  }
  pinMode(buttonPin, INPUT_PULLUP);
  pixelsA.begin();
  pixelsB.begin();
}

void loop() {
  // toggle on/off states
  checkButton();


  // send accelerometer data once every 100ms
  processData();

  if(comAvailable()>0){
    int data=comRead();
//    switch(data){
//      case 1:
//        changeMode(2);
//        break;
//      default:
//        //do nothing
//        break;
//    }
  changeMode(2);
  }
  setColors();
}

//toggles on/off
