 RunningMedian a_verticalRollingSample = RunningMedian(5);
 #define ACCELEROMETER_ORIENTATION 2     // 0, 1 or 2 to set the angle of the joystick
 int a_forward_offset=0,a_sideway_offset=0,a_vertical_offset=0;
-enum POSITION_BOUTONS { NONE, EN_HAUT,AU_DESSUS,EN_BAS,AU_DESSOUS, EN_AVANT, EN_ARRIERE, COUNT };  // Used to detect position of buttons relative to Stecchino and user
-const char *position_boutons[COUNT] = { "None", "EN_HAUT", "AU_DESSUS", "EN_BAS", "AU_DESSOUS", "EN_AVANT", "EN_ARRIERE" };
-uint8_t orientation_boutons = NONE;
+enum POSITION_STECCHINO { NONE, POSITION_1,POSITION_2,POSITION_3,POSITION_4, POSITION_5, POSITION_6, COUNT };  // Used to detect position of buttons relative to Stecchino and user
+const char *position_stecchino[COUNT] = { "None", "POSITION_1", "POSITION_2", "POSITION_3", "POSITION_4", "POSITION_5", "POSITION_6" };
+// POSITION_1: Stecchino V3/V4 horizontal with buttons up (idle)
+// POSITION_2: Stecchino V3/V4 horizontal with buttons down (force sleep)
+// POSITION_3: Stecchino V3/V4 horizontal with long edge down (spirit level)
+// POSITION_4: Stecchino V3/V4 horizontal with short edge down (opposite to spirit level)
+// POSITION_5: Stecchino V3/V4 vertical with PCB up (normal game position = straight)
+// POSITION_6: Stecchino V3/V4 vertical with PCB down (easy game position = straight)
+uint8_t orientation = NONE;
 
 unsigned long start_time=0, current_time=0, elapsed_time=0, record_time=0, previous_record_time=0;
-int i=0;
+int i=0, Vcc=0;
 float angle_2_horizon=0;
+bool Ready_4_Change=false;
 
 CRGB leds[NUM_LEDS];  // Define the array of leds
 
+//byte led_colour[NUM_LEDS];
+
 void setup() {
 
-  Serial.begin(38400);
+  Serial.begin(9600);
   while (!Serial);
 
   pinMode(PushB1,INPUT);

    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;
    

  EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow 
}

void CHECK_BATTERY_LED(int vcc){  // bargraph showing battery level
    digitalWrite(MOSFET_GATE,HIGH);
    FastLED.setBrightness(LOW_BRIGHTNESS);
    if (vcc<LOW_VCC){vcc=LOW_VCC;}
    if (vcc>HIGH_VCC){vcc=HIGH_VCC;}
    int pos_led=map(vcc,LOW_VCC,HIGH_VCC,1,NUM_LEDS);
    //Serial.println(vcc);
    //Serial.println(LOW_VCC);
    //Serial.println(HIGH_VCC);
    //Serial.println(pos_led);

    
    for (int i = NUM_LEDS; i >=0; i--){
      if (i<=pos_led){
        if (i<=5){leds[i]=CRGB::Red;}
        else if (i>5 && i<=15){leds[i]=CRGB::Orange;}
        else {leds[i]=CRGB::Green;}
        }
      else {leds[i]=CRGB::Black;}
    }
    // send the 'leds' array out to the actual LED strip
    FastLED.show();  
    // insert a delay to keep the framerate modest
    FastLED.delay(1000/FRAMES_PER_SECOND);  
    // do some periodic updates
  EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow 
}

void nextPattern()
{
  // add one to the current pattern number, and wrap around at the end
