Arduino cuts out mid serial print

I’m working on using a gamecube controller to control my arduino and have started with someone else’s project. However I can’t even seem to get their unedited code to work right. Below is the setup routine from their project.

void setup()
{
  Serial.begin(9600);

  Serial.println();
  
  Serial.println("Code has started!");

  // Status LED
  digitalWrite(13, LOW);
  pinMode(13, OUTPUT);

  // Communication with gamecube controller on this pin
  // Don't remove these lines, we don't want to push +5V to the controller
  digitalWrite(GC_PIN, LOW);  
  pinMode(GC_PIN, INPUT);

  // Communication with the N64 on this pin
  digitalWrite(N64_PIN, LOW);
  pinMode(N64_PIN, INPUT);

  // Initialize the gamecube controller by sending it a null byte.
  // This is unnecessary for a standard controller, but is required for the
  // Wavebird.
  unsigned char initialize = 0x00;
  noInterrupts();
  gc_send(&initialize, 1);

  // Stupid routine to wait for the gamecube controller to stop
  // sending its response. We don't care what it is, but we
  // can't start asking for status if it's still responding
  int x;
  for (x=0; x<64; x++) {
      // make sure the line is idle for 64 iterations, should
      // be plenty.
      if (!GC_QUERY)
          x = 0;
  }

  // Query for the gamecube controller's status. We do this
  // to get the 0 point for the control stick.
  unsigned char command[] = {0x40, 0x03, 0x00};
  gc_send(command, 3);
  // read in data and dump it to gc_raw_dump
  gc_get();
  interrupts();
  translate_raw_data();
  zero_x = gc_status.stick_x;
  zero_y = gc_status.stick_y;

  
}

I can post more of the code if it seems like it is relevant but I feel like the problem is here. When I run this and watch the serial monitor the only thing that appears is “Co” from the serial print command for “Code has started”. If I put a delay right after the Serial print it will finish but somewhere else in the setup its getting lost. The code never moves on to loop(). I’m somewhat confident with the basics of code but in this situation I really have no clue where to look. Any ideas?

KevinArduino:
I can post more of the code if it seems like it is relevant but I feel like the problem is here. When I run this and watch the serial monitor the only thing that appears is "Co" from the serial print command for "Code has started". If I put a delay right after the Serial print it will finish but somewhere else in the setup its getting lost. The code never moves on to loop(). I'm somewhat confident with the basics of code but in this situation I really have no clue where to look. Any ideas?

Please do post the ENTIRE code, or at the very least, a complete sketch that illustrates the problem.

Of course it's relevant. A Serial.begin() and a Serial.println() are not going to fail without something else having first caused a problem. For instance, we have no way of telling what pins your GameCube is connected to.

A schematic would likely help too.

Does it cut out when printing this line?

Serial.println("Code has started!");

Maybe Serial doesn't finish sending the data before execution of the code below starts.
Serial print runs on interrupts and you turn those off for maybe longer than you think.

I would also think its that noInterrputs () that is cutting off the serial output. Put a delay(100) after the Serial.print.

Paul

Ah I think you guys were right, the serial print finishes just fine with a delay. I haven't had a chance to try it yet since I'm at work but I think I'm getting stuck because I forgot a pull up resistor so the arduino never gets its response from the controller and never moves on. Thanks for the suggestion!