0

EDIT: My original question was a bit "off" since the Arduino Nano I was using appeared to be faulty. This edited question is based on my other Arduino Nano which is working.

When I plug my Arduino into the PC, it keeps blinking it's LED until I open the Serial Monitor.

After opening the serial monitor the Arduino will start to execute my code.

How can I get my Arduino to "not wait on a connection", or simply put, start whenever it receives power.

I believe it's the bootloader which somehow doesn't time-out (I'm not sure if that's how the bootloader works).

The code below (though I don't see why this would make it hang until a connection):

void setup() {
  // put your setup code here, to run once:
  Serial.begin(256000);
  Serial.write("Restart");
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available() > 0) {
    incomingByte = Serial.read();

    // say what you got:
    startSend();
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
    stopSend();
  }else{
    startSend();
    Serial.println("I'm still standing");
    stopSend();
    delay(400);
  }
}

(Code is only for testing purposes)

2
  • It's likely people will need to see your code (sketch) in your question in order to help.
    – st2000
    May 1, 2016 at 14:21
  • I've just changed board, and it seems to work a lot better. But it still seems Arduino won't start until I open the serial monitor.
    – aaa
    May 1, 2016 at 14:59

1 Answer 1

0

After you post your code this answer may not apply. But, guessing, you may benefit from changing your code from:

loop()
{
 data = Serial.read();
 // Do other sutff
}

To something like this:

loop()
{
 if(Serial.available() > 1)
 {
  data = Serial.read();
 }
 // Do other stuff
}
2
  • Hmm, it appeared to be some vague hardware problem. My CH340G board runs fine, the FTDI (from China) doesn't, I think it's a fake.
    – aaa
    May 1, 2016 at 14:38
  • And, the code won't upload while I have it connected to the MAX485, I think it might "drain the bits".
    – aaa
    May 1, 2016 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.