   // Get median
   int a_forwardRollingSampleMedian=a_forwardRollingSample.getMedian()-a_forward_offset;
   int a_sidewayRollingSampleMedian=a_sidewayRollingSample.getMedian()-a_sideway_offset;
-  //int a_verticalRollingSampleMedian=a_verticalRollingSample.getMedian()-a_vertical_offset+100;
-  int a_verticalRollingSampleMedian=a_verticalRollingSample.getMedian()-a_vertical_offset-100; 
-  
-  // for debugging
-  //Serial.print("a_forward:");
-  //Serial.print(a_forwardRollingSampleMedian);
-  //Serial.print(" a_sideway:");
-  //Serial.print(a_sidewayRollingSampleMedian);
-  //Serial.print(" a_vertical:");
-  //Serial.println(a_verticalRollingSampleMedian);
-  
-    
+  int a_verticalRollingSampleMedian=a_verticalRollingSample.getMedian()-a_vertical_offset; 
+  
   // Evaluate current condition based on smoothed accelarations
   accel_status="unknown";
   if (abs(a_sidewayRollingSampleMedian)>abs(a_verticalRollingSampleMedian)||abs(a_forwardRollingSampleMedian)>abs(a_verticalRollingSampleMedian)){accel_status="fallen";}
   if (abs(a_sidewayRollingSampleMedian)<abs(a_verticalRollingSampleMedian)&&abs(a_forwardRollingSampleMedian)<abs(a_verticalRollingSampleMedian)){accel_status="straight";}
   //else {accel_status="unknown";}
 
-  if (a_verticalRollingSampleMedian >= 80 && abs(a_forwardRollingSampleMedian) <= 25 && abs(a_sidewayRollingSampleMedian) <= 25 && orientation_boutons != EN_HAUT) {
+  if (a_verticalRollingSampleMedian >= 80 && abs(a_forwardRollingSampleMedian) <= 25 && abs(a_sidewayRollingSampleMedian) <= 25 && orientation != POSITION_6) {
     // coté 1 en haut
-    orientation_boutons = EN_HAUT;
-  } else if (a_forwardRollingSampleMedian >= 80 && abs(a_verticalRollingSampleMedian) <= 25 && abs(a_sidewayRollingSampleMedian) <= 25 && orientation_boutons != AU_DESSUS) {
+    orientation = POSITION_6;
+  } else if (a_forwardRollingSampleMedian >= 80 && abs(a_verticalRollingSampleMedian) <= 25 && abs(a_sidewayRollingSampleMedian) <= 25 && orientation != POSITION_2) {
     // coté 2 en haut
-    orientation_boutons = AU_DESSUS;
-  } else if (a_verticalRollingSampleMedian <= -80 && abs(a_forwardRollingSampleMedian) <= 25 && abs(a_sidewayRollingSampleMedian) <= 25 && orientation_boutons != EN_BAS) {
+    orientation = POSITION_2;
+  } else if (a_verticalRollingSampleMedian <= -80 && abs(a_forwardRollingSampleMedian) <= 25 && abs(a_sidewayRollingSampleMedian) <= 25 && orientation != POSITION_5) {
     // coté 3 en haut
-    orientation_boutons = EN_BAS;
-  } else if (a_forwardRollingSampleMedian <= -80 && abs(a_verticalRollingSampleMedian) <= 25 && abs(a_sidewayRollingSampleMedian) <= 25 && orientation_boutons != AU_DESSOUS) {
+    orientation = POSITION_5;
+  } else if (a_forwardRollingSampleMedian <= -80 && abs(a_verticalRollingSampleMedian) <= 25 && abs(a_sidewayRollingSampleMedian) <= 25 && orientation != POSITION_1) {
     // coté 4 en haut
-    orientation_boutons = AU_DESSOUS;
-  } else if (a_sidewayRollingSampleMedian >= 80 && abs(a_verticalRollingSampleMedian) <= 25 && abs(a_forwardRollingSampleMedian) <= 25 && orientation_boutons != EN_AVANT) {
+    orientation = POSITION_1;
+  } else if (a_sidewayRollingSampleMedian >= 80 && abs(a_verticalRollingSampleMedian) <= 25 && abs(a_forwardRollingSampleMedian) <= 25 && orientation != POSITION_3) {
     // coté LEDs en haut
-    orientation_boutons = EN_AVANT;
-  } else if (a_sidewayRollingSampleMedian <= -80 && abs(a_verticalRollingSampleMedian) <= 25 && abs(a_forwardRollingSampleMedian) <= 25 && orientation_boutons != EN_ARRIERE) {
+    orientation = POSITION_3;
+  } else if (a_sidewayRollingSampleMedian <= -80 && abs(a_verticalRollingSampleMedian) <= 25 && abs(a_forwardRollingSampleMedian) <= 25 && orientation != POSITION_4) {
     // coté batteries en haut
-    orientation_boutons = EN_ARRIERE;
+    orientation = POSITION_4;
   }  else {
     // orientation = FACE_NONE;
   }
-  
- //Serial.print(" - ");
- //Serial.print(position_boutons[orientation_boutons]);
- //Serial.print(" - ");
- //Serial.println(accel_status);
 
  angle_2_horizon=atan2(float(a_verticalRollingSampleMedian),float(max(abs(a_sidewayRollingSampleMedian),abs(a_forwardRollingSampleMedian))))*180/PI;
- //Serial.print(" ");
- //Serial.println(angle_2_horizon);
- return angle_2_horizon;
+
+  /*
+  // for debugging
+  Serial.print("a_forward:");
+  Serial.print(a_forwardRollingSampleMedian);
+  Serial.print(" a_sideway:");
+  Serial.print(a_sidewayRollingSampleMedian);
+  Serial.print(" a_vertical:");
+  Serial.print(a_verticalRollingSampleMedian);
+  Serial.print(" - ");
+  Serial.print(position_stecchino[orientation]);
+  Serial.print(" - ");
+  Serial.print(accel_status);
+  Serial.print(" - ");
+  Serial.println(angle_2_horizon);
+  */
+  
+   return angle_2_horizon;
  }
 
 

    break;
    
  case Idle:      
    if (millis()-start_time>SET_IDLE_MILLISECONDS){condition=Fake_Sleep;start_time=millis();}
    if (accel_status=="straight"){condition=Start_Play_Transition;start_time=millis();}
    if (orientation_boutons==EN_AVANT){condition=Spirit_Level;start_time=millis();}
    else {LED("idle");}
    break;
    

    elapsed_time=(millis()-start_time)/1000;
    if (elapsed_time>record_time){record_time=elapsed_time;}
    if (elapsed_time>previous_record_time && elapsed_time<=previous_record_time+1 && previous_record_time !=0){LED("wahoo");}
    if (elapsed_time>SET_MAX_PLAY_SECONDS){condition=Sleep_Transition;start_time=millis();}
    else {LEDS_ON(NUM_LEDS_PER_SECONDS*int(elapsed_time),NUM_LEDS_PER_SECONDS*int(record_time));} 
    if (accel_status=="fallen"){condition=Game_Over_Transition;start_time=millis();}
    break;
