How do you go to a specific void that's in a order?

My code is simulating the traffic lights of a intersection but they need buttons to make certain LEDs to turn on like the sensors within the street does. My code is timed with one green LED being on and a red LED being on at the same time and then going through a sequence where one side is red and the other is green completely switching.

int switchState = 0;
int GREEN = 2;
int YELLOW = 3;
int RED = 4;
int GOU = 11;
int WOLLEY = 12;
int DER = 13;
int BLUE = 6;
int AQUA = 8;
int SwitchA = 8;
int SwitchB = 7;
int SwitchC = 9;
int SwitchD = 10;
int DELAY_GREEN = 5000;
int DELAY_YELLOW = 2000;
int DELAY_RED = 5000;
int DELAY_GOU = 5000;
int DELAY_WOLLEY = 2000;
int DELAY_DER = 5000;

void setup()
{
  pinMode(GREEN, OUTPUT);
  pinMode(YELLOW, OUTPUT);
  pinMode(RED, OUTPUT);
  pinMode(BLUE, OUTPUT);
  pinMode(AQUA, OUTPUT);
  pinMode(GOU, OUTPUT);
  pinMode(WOLLEY, OUTPUT);
  pinMode(DER, OUTPUT);
  pinMode(SwitchA, INPUT);
  pinMode(SwitchB, INPUT);
  pinMode(SwitchC, INPUT);
  pinMode(SwitchD, INPUT);
}

void loop()
{
  green_light();
  delay(DELAY_GREEN);
  yellow_light();
  delay(DELAY_YELLOW);
  red_light();
  delay(DELAY_RED);
  wolley_light();
  delay(DELAY_WOLLEY);
  
}

void green_light()
{
  digitalWrite(GREEN, HIGH);
  digitalWrite(YELLOW, LOW);
  digitalWrite(RED, LOW);
  digitalWrite(DER, HIGH);
  digitalWrite(WOLLEY, LOW);
  digitalWrite(GOU, LOW);
  digitalWrite(BLUE, LOW);
  digitalWrite(AQUA, HIGH);
  }

void yellow_light()
{
  digitalWrite(GREEN, LOW);
  digitalWrite(YELLOW, HIGH);
  digitalWrite(RED, LOW);
  digitalWrite(GOU, LOW);
  digitalWrite(WOLLEY, LOW);
  digitalWrite(DER, HIGH);
  
}

void wolley_light()
{
  digitalWrite(GREEN, LOW);
  digitalWrite(YELLOW, LOW);
  digitalWrite(RED, HIGH);
  digitalWrite(GOU, LOW);
  digitalWrite(WOLLEY, HIGH);
  digitalWrite(DER, LOW);
  
  
}


void red_light()
{
  digitalWrite(GREEN, LOW);
  digitalWrite(YELLOW, LOW);
  digitalWrite(RED, HIGH);
  digitalWrite(DER, LOW);
  digitalWrite(WOLLEY, LOW);
  digitalWrite(GOU, HIGH);
  digitalWrite(BLUE, HIGH);
  digitalWrite(AQUA, LOW);
  
}

...apparently absent

A void is not a thing. We call that a function.

do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation for your ask).

Why do you want your code to run voids?

Would you rather your code run functions based upon conditions?

I feel so empty without them...

A function is like a "mini program" or a "detour" from your main program. For example maybe your function turns a servo motor or X-degrees, or something like that.

You can pass one or more variable values into the function (like the degrees for the servo). Except with a servo, you're probably using a servo library so although you're calling a function the code for the function is "hidden" in the library.

A function can optionally return ONE value (like a function that makes a calculation). A function that does not return a value is a void function.

Typically, you'll make a function when you find yourself writing the same code over-and-over. If your code is doing something that takes 10 lines of code and you've repeated those same exact 10 lines 3 places in your program, you can make a function.

The confusing thing about a function is that it has a declaration, which says what type of variable is returned (or if it's void), the name of the function, and the types of variables to be passed-into the function.

Then it has a definition which looks similar to the declaration, but it has the actual code and the names for the variables used inside the function, which can be different from the names passed-in. You are passing-in the variable-value, not the name.

Finally there are function calls, which also look similar, but this is where you code takes that "detour" to actually run the function. The function can be called multiple times from different places in the code.

if-statements or switch/case statements. This is called "conditional execution" and it's how programs "make decisions" and it's one of the most important concepts in programming. The other important concept is looping... Doing something over-and-over, usually until some condition is reached.

Assuming you know by now they are called functions. To call them from within the loop function simply use their name with any number you want to pass to it in the brackets.

flash(3):

where you define the function flash() outside any other function like

void flash(int number_of_flashes){ // flash an LED a number of times
for int i = 0; i< number_of_flashes; i++){
    digitalWrite(ledPin, HIGH);
    delay(400);
    digitalWrite(ledPin, LOW);
    delay(400);
   }
}

You might want to precede the call to the function call with an if statement.

Maybe he is actually asking about the goto statement. And he wants to just jump somewere in the "loop" function of Arduino.
If this is the actual question, then read this: goto - Arduino Reference

...and then immediately forget you ever heard of it.

Yeah. Using goto is lame and if someone really uses them there is something fishy with the code logic.
But, as you already said in the first post, it's really hard to understand what he really wants without a code, so if he just wants to use goto... then we can't stop him.

No we can't. But we do not need to evangelize its use, or suggest it as a solution to anything, because it isn't. if it ever would be, C has better ways of doing it and C++ have even better ways. If there is a situation that goto might solve that C or C++ seemingly can't, it's very likely an XY problem, or problem in the programmer's logic or code structure.

Ok I add in the code. Basically I want the switches to skip to certain functions.

If you don't mind me asking what's wrong with using a goto is there like a better way of skipping to one function?

int switchState = 0;
int GREEN = 2;
int YELLOW = 3;
int RED = 4;
int GOU = 11;
int WOLLEY = 12;
int DER = 13;
int BLUE = 6;
int AQUA = 8;
int SwitchA = 8;
int SwitchB = 7;
int SwitchC = 9;
int SwitchD = 10;
int functionIndex;
int D3L4Y[4] = {5000, 2000, 5000, 2000};
int DELAY_GREEN = 5000;
int DELAY_YELLOW = 2000;
int DELAY_RED = 5000;
int DELAY_GOU = 5000;
int DELAY_WOLLEY = 2000;
int DELAY_DER = 5000;

void green_light() {
  digitalWrite(GREEN, HIGH);
  digitalWrite(YELLOW, LOW);
  digitalWrite(RED, LOW);
  digitalWrite(DER, HIGH);
  digitalWrite(WOLLEY, LOW);
  digitalWrite(GOU, LOW);
  digitalWrite(BLUE, LOW);
  digitalWrite(AQUA, HIGH);
}

void yellow_light() {
  digitalWrite(GREEN, LOW);
  digitalWrite(YELLOW, HIGH);
  digitalWrite(RED, LOW);
  digitalWrite(GOU, LOW);
  digitalWrite(WOLLEY, LOW);
  digitalWrite(DER, HIGH);
}

void wolley_light() {
  digitalWrite(GREEN, LOW);
  digitalWrite(YELLOW, LOW);
  digitalWrite(RED, HIGH);
  digitalWrite(GOU, LOW);
  digitalWrite(WOLLEY, HIGH);
  digitalWrite(DER, LOW);
}


void red_light() {
  digitalWrite(GREEN, LOW);
  digitalWrite(YELLOW, LOW);
  digitalWrite(RED, HIGH);
  digitalWrite(DER, LOW);
  digitalWrite(WOLLEY, LOW);
  digitalWrite(GOU, HIGH);
  digitalWrite(BLUE, HIGH);
  digitalWrite(AQUA, LOW);
}

void (*functionPointer[4])() = {green_light, yellow_light, red_light, wolley_light};

void setup() {
  pinMode(GREEN, OUTPUT);
  pinMode(YELLOW, OUTPUT);
  pinMode(RED, OUTPUT);
  pinMode(BLUE, OUTPUT);
  pinMode(AQUA, OUTPUT);
  pinMode(GOU, OUTPUT);
  pinMode(WOLLEY, OUTPUT);
  pinMode(DER, OUTPUT);
  pinMode(SwitchA, INPUT);
  pinMode(SwitchB, INPUT);
  pinMode(SwitchC, INPUT);
  pinMode(SwitchD, INPUT);
}

void loop() {
  if (functionIndex >= 3) functionIndex = 0 ;
  else functionIndex++;
  (*functionPointer[functionIndex])();
  delay(D3L4Y[functionIndex]);
}

A instructs you to goto B which instructs you to goto A which instructs you to goto B.

The problem with goto is that it was created for BASIC, a procedural language, and after time, C was written to address many of the pitfalls of BASIC, including Goto, and C is called a structural language. So, we can have functions that are called instead of goto subroutines, that required a goto to "skip" or else you ran into an unwanted loop or what is called "spaghetti programming".

Thank you but I should have been more specific. The switches are buttons and I'm trying to just have them be linked to certain functions and when pressed just go to a specific place in the sequence.

If you look in my code, I have given each function a pointer in an array, so you can call a function simply by calling the function pointer array and indexing to the function numerically.

if (digitalRead(SwitchA) == HIGH) (*functionPointer[0])();

pseudo code:

void setup() {

  // put your setup code here, to run once:

}

void loop() {
  if (buttonA pressed) {
    functionA();
  }

  if (buttonB pressed) {
    functionB();
  }
}

void functionA() {
  do functionA stuff
}

void functionB() {
  do functionB stuff
}