switch case question (solved) silly mistake

Doing some playing with switch case. The following recognizes the case when it is typed but the call to the void function doesn't work. The Serial.print part does so I know I have it somewhat right. Is that something that isn't allowed?

The idea behind the test was to replace a ton of IF statements. I have 7 direction functions that are called from IF statements comparing against serial input. It works perfectly but I want to keep learning and improving it.

So, can you not call a void function from a switch case?

byte state;
void setup() {
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available() > 0)  // Checks whether data is coming from the serial port
  {
    state = Serial.read(); // Reads the data from the serial port
  }

  switch (state)
  {
    case '1': void hermon();  Serial.println("1");
      break;
    case '2': void steve(); Serial.println("2");
      break;
  }
}

void hermon()
{
  Serial.println("1 was pressed");
}

void steve()
{
  Serial.print("2 was pressed");
}
case '1': void hermon();  Serial.println("1");
      break;
    case '2': void steve(); Serial.println("2");
      break;

Your syntax is wrong for calling a function. The return type is only used in the declaration.
See this tutorial Arduino Functions | How To Program and Use a Function

case '1': hermon();  Serial.println("1");
      break;
    case '2':  steve(); Serial.println("2");
      break;

I think you should remove

case '1': void hermon(); Serial.println("1");

to:

case '1': hermon(); Serial.println("1");

Yes yes yes yes yes...... I have been reading and JUST came back to say I found it.lol
Thanks everyone. I'm an idiot :slight_smile:
Don't know why I put the "void" there but hey. That's how I learn anyway. My working sketch has about 15 different function calls in it so it isn't like I've not done it before.
Thanks again