Arduino running without PC connection?

Hi guys,

I have an Arduino NANO which i will need to run for data logging without being connected to the PC.

Right now i am running an SD Card Reader connected to the NANO. I have modified it to blink an LED while writing to the card. Here is the code:

#include <SPI.h>
#include <SD.h>
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
 pinMode(7, OUTPUT);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(10)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("This is a test file :)");
myFile.println("testing 1, 2, 3.");
for (int i = 0; i < 20; i++) {
  digitalWrite(7, HIGH);
myFile.println(i);
delay(1000);
digitalWrite(7, LOW);
delay(1000);
}
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop() {
// nothing happens after setup
}

There is no problem in the wiring, it is set up according to the various tutorials. When running from the PC then everything is fine, and the output file is just as expected.

HOWEVER: I have tried 2 different setups after having loaded the code to the Arduino:

-Powering up from an external power source 5V 1A (output voltage 4,88V) or PC USB connected to power bus (4,97V). The POW LED lights up, L and TX blink up and then remain dark. Program does not start…nothing happens. As soon as USB data is plugged in, the program beginns to run.

-Powering up from USB+external. The program starts, the check-LED on Pin 7 blinks as expected, all normal. If i now disconnect the USB while writing, then the program runs on, the LED blinks the rest of the 20 write cycles. The file is created on the card, but there is none of the testdata…

So SD writing does not work from external power, neither does startup from external power…
Any hints where im going wrong?

Powering up from an external power source 5V 1A (output voltage 4,88V) or PC USB connected to power bus (4,97V). The POW LED lights up, L and TX blink up and then remain dark. Program does not start.....nothing happens. As soon as USB data is plugged in, the program beginns to run.

External power plug runs through a linear voltage regulator, so the input voltage must be greater than 7V. If you apply 5V the voltage regulator won't be able to supply enough power for the UNO.

So SD writing does not work from external power, neither does startup from external power.... Any hints where im going wrong?

It does work if you provide the correct power.

Ahhhhhh! OK i see. I just tried connecting the +5V to the 5V Pin, now it works fine. Thanks!