Swtich/case statments: No luck!

Hey!

I can't get any swtich/case statements working.

Here's mine:

swtich (switchState)
{
case 0:
      if (menuItem == 1)
      {menuItem= 5;}
      else
      {menuItem--;}
        break;
case 1:
      (if menuItem == 5)
      {menuItem=0;}
      else
      {menuItem++;}
        break;
case 3:
      menuItem=6:
        break;
}

all the variables are ints, and are defined ect. I get the error:

error: 'swtich' was not declared in this scope

So, i copied and pasted the example from Arduino.cc:

 int var = 1;
 
  switch (var) {
    case 1:
      //do something when var == 1
      break;
      // break is optional
    case 2:
      //do something when var == 2
      break;
    default: 
      // if nothing else matches, do the default
      // default is optional
  }

and i get the error:

error: expected unqualified-id before 'switch'

What the devil am i doing wrong?

Cheers!

Nick D

Hi Nick

You typed swtich when you intended switch

And the example code is missing an expression in the default statement.

Add a semicolon after default: (or remove the default statement) and it should compile

Good luck!

Dyslexia strikes again!