Help with use of goto

I got it to compile by making label1() and label2() into functions that can be called, and got rid of the print() function.

int a = 0;
void setup() {
  Serial.begin(9600);
  int a = 0;
}

void label2() {
  Serial.println("label2 has sent me back to label1");
  label1();
}
void label1() {
  Serial.println("am at label1");

  for (int a = 0; a < 100; a++)
  {
    Serial.println(a);
    delay(100);
  }
  if ( a >= 50)
  { Serial.println("going to label2");
    label2();
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  //label2: Serial.println("am at label2");
  delay(5000);
  label1();
}
1 Like