Problem with millis() timing

could you please modify it for me?

I can almost guarantee you won't see any difference in object code size by using an extra automatic variable (buttonState1) here. The compiler is very good at optimizing the generated code (sometimes in ways that surprise me, and I've been programming in C for 25 years).

case 3:
    currentMillis = millis();
    diff = currentMillis - startMillis;
    if(buttonState == HIGH)
      {
      if(diff < debounce)
        {
        switch_1 = 0;
        }
      else if (diff<longPeriod)
        {
        switch_1 = 4;      
        }
      }
    if((diff >= longPeriod)
    {
      switch_1 = 6;
    }
    break;

WOW! itried something similar, but only worked if i always released the button! this one works fine! thanks a lot!

now i understand why that buttonState == HIGH was at the wrong place with going back to switch_1 = 0;

Ive not programmed in C and I've only been doing these uP thingies for 2.5 years. Thanks for the history lesson.