Newbie error uploading.

This is like my second code, I verified succesfully. But when I upload it compiles fine and then just freezes in upload phase. Then if I try to re upload it comes up with “Com4 port” in use. I searched through some forums and came across a driver issue I reinstalled up to date drivers.

Using ardruino Mega 2560.

Any help would be great. I tried including a bunch of delays just incase it was looping really fast causing it to not upload. ^.^

Thanks Guys!

void setup()
{
Serial.begin(9600);
pinMode(2, INPUT);
pinMode(3, INPUT);
Serial.println(“Welcome to the games, press the Left button to begin”);
delay (200);

}

void loop()
{
if (digitalRead(3) == HIGH)
{
Serial.println(“Welcome to the games”);
delay(1000);
GameRun();
delay(1000);
}
delay(4000);
}
void GameRun()
{
Serial.print("Press the Left Button to WIN ");
delay(4000);
Serial.print(“Press the Right button to LOSE”);
delay(60000);

if (digitalRead(3) == HIGH)
{
Serial.println(“Winner!”);
delay(200);
}
if (digitalRead(2) == HIGH)
{
Serial.println(“Loser!”);
delay(200);
}
delay(400);
}

Using Stnd Library o external libraries.

Thanks again in advance, I tried trouble shooting before posting. :roll_eyes:

Uploading and running of the sketch are entirely separate stages so adding delay()s in the code is a red herring. There is probably an issue with the COM port - perhaps some other software is trying to talk to it, maybe its jammed up.

Try restarting the Arduino IDE, rescanning for ports with the relevant menu. Try removing the USB cable and replugging it, etc etc.

Thanks for the reply, I tried all those things to no avail. The thing is I tried uploading BLINK and was successful, but it didn't work for this bit of code.

I cleaned it up, simplified it a bit and seems to be working now. Thanks!

void setup() { Serial.begin(9600); pinMode(2, INPUT); // the start button pinMode(3, INPUT); // the stop button Serial.println("Welcome to the Games!"); delay(2000); Serial.println("Press the Left buttong to win & Press the Right Button to lose"); }

void loop() { if (digitalRead(2) == HIGH) {

Serial.println("Congratulations you know your left from Right"); delay(1000); } if (digitalRead(3) == HIGH) { Serial.println("You failed"); delay(1000); setup();

} }