3

I am having trouble with my Arduino Mega with getting the program to start when the Arduino is plugged into a computer via USB. All that happens is the LED turns on and stays on. The device does not initialize, and only when I press the reset button does it begin the setup. How can I make the Arduino start the program when it is first plugged into the computer?

EDIT: my code

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("test");
}

very simple, which is why i don't understand why this is happening

  • The arduino will start executing immediately, unless you have serial statements looking for a connection holding up execution. can you share your code? – sspence65 Aug 16 '16 at 13:25
  • As said by @sspence65, the Arduino starts as soon as you power it. You are simply missing the startup message because it is sent before you open the serial connection on the PC end. – Edgar Bonet Aug 16 '16 at 14:47
  • 1
    Actually the message is sent repeatedly but the arduino will probably reset a second time when the virtual serial port is opened. – Chris Stratton Aug 16 '16 at 23:31
  • @ChrisStratton, actually it doesn't reset and that is another problem I am having. For some reason when the connection is established, the Arduino does not reset and sometimes there is already data in the buffer and it confuses the program and often I have to restart the program one the buffer has been read empty – vcapra1 Aug 17 '16 at 0:18
  • Try explicitly toggling RTS and DTR via your computer's serial api. At some point you may need to look into details of the USB serial implementation on your specific "mega". – Chris Stratton Aug 17 '16 at 0:39
1

I would recommend you to follow the following instructions step by step to verify your Arduino Mega.

  1. Reboot your computer
  2. Connect the Arduino using the USB cable to PC and check the Arduino itself if there is any jumper wires connected/grounded. If there are then remove them all.
  3. Upload a blank sketch first. Go to File -> New
  4. Verify the Arduino has accepted the blank sketch and resetted.
  5. Upload the Blink sketch from the File -> Examples -> 0.1Basics -> Blink
  6. Verify if the Pin 13/onboard LED is blinking. If yes then go to uploading your sketch, if no then there is a hardware/bootloader problem with your Arduino. Watch this video on how to burn bootloader here. https://www.youtube.com/watch?v=X5achE10rCI

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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