Issue at power on

Dear Friends,
I am working with Arduino Uno rev.3, I have finished my code, uploaded on the Arduino Board, and all works fine! :wink:
The problem is that when I remove the board from the Pc, and I give a new power on, the board doesn't work anymore...it is all still...
Only attaching the board to the Pc and uploading the code again, I can see the Arduino working again...
Do you have some suggestion for me, please?

I tried to connect a 10kOhm resistor between Rx pin (pin0) and ground (gnd), without any result: at the power on with external power supply, the board blinks led13 twice and then stops, without starting the code previously uploaded.

Problem solved! :slight_smile:
I had an issue in the setup() of the board: when you declare the Serial.begin() only for debugging test, the board wants the PC to communicate with...without it, the board can't go on and then stop there! :wink:

dtluigi:
Problem solved! :slight_smile:
I had an issue in the setup() of the board: when you declare the Serial.begin() only for debugging test, the board wants the PC to communicate with...without it, the board can't go on and then stop there! :wink:

That is not the problem, the board does not have to be connected to the PC to run a sketch that has already been uploaded to it. But perhaps the code in your sketch does not do anything useful unless if first receives something from the serial link?

Lefty

I had a similar problem with a Leonardo, not a Uno, because of the line that waits for Serial to become available:

void setup ()
  Serial.begin (115200);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // whatever
  }  // end of setup

However that shouldn't happen on the Uno.

I've recently tried your (Nick Gammon) I2C scanner (unmodified), which has this "while (not serial)" line in it on my uno.
The scanner waits for the serial connection to be established and only then runs the scanner once.

I modified it to (as practice) have the actual scanner in void loop() so now it runs continually after the serial connetion is up.
So i guess this also works for uno, even if you don't need to do that.
If OP has this code, he should comment it out and have another try at it.

The HardwareSerial library (such as used by the Uno) just implements the "wait" as something that immediately returns:

HardwareSerial::operator bool() {
	return true;
}

So it doesn't really wait for anything. They just put that code there so you could add the lines:

   while (!Serial) { }

... and not have to care whether this was compiled for the Uno or the Leonardo.

retrolefty:

dtluigi:
Problem solved! :slight_smile:
I had an issue in the setup() of the board: when you declare the Serial.begin() only for debugging test, the board wants the PC to communicate with...without it, the board can't go on and then stop there! :wink:

That is not the problem, the board does not have to be connected to the PC to run a sketch that has already been uploaded to it. But perhaps the code in your sketch does not do anything useful unless if first receives something from the serial link?

Lefty

If in the Setup() you have defined the Serial.begin() it needs a communication on the serial interface...if you haven't the setup of the serial, the board shows no problem to work with the previously uploaded sketch, away from the Pc.