A switch case within a switch case.

I'v gone a little of track and just confused myself could someone show me an example of what a switch case within a switch case would look like. What i'm doing is simple or well should be i'm stuck on the code for what i'm doing the code is running an RGB led and the controls are two push buttons so every you press the first button it go's to the next colour and every time you press the second button it go's to a different flashing mode. Anyone?

What have you tried?

It might be better to put the inner switch in a separate function, but it's hard to tell without seeing your code.

I made a code for just one button that worked grate but it had to many things to cycle throw so thought adding the exstar button would be easy i just well take a look its not pretty and last time i posted it up i got mugged off about it P.s don't ask what i thought i was doing i have know idea haha.

const int redledPin = 2;
const int greenledPin = 1;
const int blueledPin = 0;
const int buttonPin = 3;
const int buttonPin2 = 4;
int RGB=1;
int B2=2;

int prevUp = HIGH;
int prevDn = HIGH;

void setup ()
{
  pinMode (redledPin, OUTPUT);
  pinMode (greenledPin, OUTPUT);
  pinMode (blueledPin, OUTPUT);
  pinMode (buttonPin, INPUT);
  }

void loop ()
{
int currUp = digitalRead(buttonPin2);

   if(currUp != prevUp)
   {
      delay(5);

      currUp = digitalRead(buttonPin2);

      if(currUp != prevUp)
      {
         if(currUp == LOW)
            B2++;
      }
   }
  
   switch (B2)
     case 1:{
  {
int currUp = digitalRead(buttonPin);

   if(currUp != prevUp)
   {
      delay(5);

      currUp = digitalRead(buttonPin);

      if(currUp != prevUp)
      {
         if(currUp == LOW)
            RGB++;
      }
   }
  
   switch (RGB){
    case 1:
    analogWrite(redledPin, 0);
    analogWrite(blueledPin, 250);
    analogWrite(greenledPin, 0);
    delay(200);
    analogWrite(redledPin, 0);
    analogWrite(blueledPin, 250);
    analogWrite(greenledPin, 0);
    delay(100);
    break;
    
    case 2:
    analogWrite(redledPin, 0);
    analogWrite(blueledPin, 250);
    analogWrite(greenledPin, 0);
    break;
   
   }
    prevUp = currUp;
}
break;

  case 2:{
int currUp = digitalRead(buttonPin);

   if(currUp != prevUp)
   {
      delay(5);

      currUp = digitalRead(buttonPin);

      if(currUp != prevUp)
      {
         if(currUp == LOW)
            RGB++;
      }
   }
  
   switch (RGB){
    case 1:
    analogWrite(redledPin, 0);
    analogWrite(blueledPin, 0);
    analogWrite(greenledPin, 250);
    delay(200);
    analogWrite(redledPin, 0);
    analogWrite(blueledPin, 0);
    analogWrite(greenledPin, 0);
    delay(100);
    break;
    
    case 2:
    analogWrite(redledPin, 0);
    analogWrite(blueledPin, 0);
    analogWrite(greenledPin, 250);
    
   }
    prevUp = currUp;
  }break;
   }
 }

It would be easier to follow if you applied the auto-format tool

There we go : )

const int redledPin = 2;
const int greenledPin = 1;
const int blueledPin = 0;
const int buttonPin = 3;
const int buttonPin2 = 4;
int RGB=1;
int B2=2;

int prevUp = HIGH;
int prevDn = HIGH;

void setup ()
{
  pinMode (redledPin, OUTPUT);
  pinMode (greenledPin, OUTPUT);
  pinMode (blueledPin, OUTPUT);
  pinMode (buttonPin, INPUT);
}

void loop ()
{
  int currUp = digitalRead(buttonPin2);

  if(currUp != prevUp)
  {
    delay(5);

    currUp = digitalRead(buttonPin2);

    if(currUp != prevUp)
    {
      if(currUp == LOW)
        B2++;
    }
  }

  switch (B2)
  case 1:
  {
    {
      int currUp = digitalRead(buttonPin);

      if(currUp != prevUp)
      {
        delay(5);

        currUp = digitalRead(buttonPin);

        if(currUp != prevUp)
        {
          if(currUp == LOW)
            RGB++;
        }
      }

      switch (RGB){
      case 1:
        analogWrite(redledPin, 0);
        analogWrite(blueledPin, 250);
        analogWrite(greenledPin, 0);
        delay(200);
        analogWrite(redledPin, 0);
        analogWrite(blueledPin, 250);
        analogWrite(greenledPin, 0);
        delay(100);
        break;

      case 2:
        analogWrite(redledPin, 0);
        analogWrite(blueledPin, 250);
        analogWrite(greenledPin, 0);
        break;

      }
      prevUp = currUp;
    }
    break;

  case 2:
    {
      int currUp = digitalRead(buttonPin);

      if(currUp != prevUp)
      {
        delay(5);

        currUp = digitalRead(buttonPin);

        if(currUp != prevUp)
        {
          if(currUp == LOW)
            RGB++;
        }
      }

      switch (RGB){
      case 1:
        analogWrite(redledPin, 0);
        analogWrite(blueledPin, 0);
        analogWrite(greenledPin, 250);
        delay(200);
        analogWrite(redledPin, 0);
        analogWrite(blueledPin, 0);
        analogWrite(greenledPin, 0);
        delay(100);
        break;

      case 2:
        analogWrite(redledPin, 0);
        analogWrite(blueledPin, 0);
        analogWrite(greenledPin, 250);

      }
      prevUp = currUp;
    }
    break;
  }
}

The syntax is correct because it compiles. However I suspect you think it is wrong because it doesn't do what you want.
You seem to be using pins 0 and 1 for outputs and you seem to be using non PWM pins as PWM pins.

But your braces look wrong, the whole of that code is just a case 1, did you mean it to be.

By clicking on an opening brace the matching closing brace is outlined. Try it.

Ok will try that dude o and the pins are set to 0,1,2 etc.. because i'm using an ATtiny85.

Yes where you have

 switch (B2)
  case 1:
  {

If you click on that brace the matching brace is the second to last one in the sketch, which I am sure you do not mean.

I'm shore i didn't mean to but like i said i'm a little bit out of my depth here so not really shore anymore haha.

Could someone show me an example of what i could do to fix my code i'm really new to all of this and i'm struggling : /

Just delete the second to end brace and put it at the end of what you want to do for case 1 when you switch off the value of B2.