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?