 int dimVal=200;
 int readyForChange=1;
 
+int dimTimeValuesAmount=20;
+int dimTimeValues[20];
+
+
+
+void updataDimTimeValues(int value){
+  for (int i=0; i < (dimTimeValuesAmount -1); i++){
+    int tm = dimTimeValues[i];
+    int j= i+1;
+    dimTimeValues[j] = tm;
+  }
+  dimTimeValues[0]=value;
+}
+
+
+
+
 
 int pwmOut=9;
 
 unsigned long lastTime;
 int timeDelta=500;
+
+
+
+
+
+
+
 
 
 void switchState(){

  if(dimVal > maxDim){
    dimVal = maxDim;
  }
  
}

  
  if(state == 1){
    analogWrite(pwmOut,dimVal);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255  
  }else if(state == 0){
    analogWrite(pwmOut,0);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255  

  }


   Serial.print("STATE: ");
   Serial.print(state);
   
   Serial.print("   HAND: ");
   Serial.print(handposition);


  Serial.print("   IR Val:"); 

  Serial.print(irSensorVal);

   Serial.print("   DIMVAL: ");
   Serial.print(dimVal);
    
  Serial.println("");

}


    }
      handposition=0;
      dimMode=0;
      dimVal=dimTimeValues[(dimTimeValuesAmount-1)];
  }


