mbreedlove
mbreedlove

Reputation: 336

Arduino stuck in an infinite loop

My Arduino is stuck in an infinite loop trying to read from a pin and print it to the serial console. I can't upload any other programs now. What can I do to get the chip out of the loop?

Upvotes: 7

Views: 13496

Answers (7)

James Mulling
James Mulling

Reputation: 75

The Arduino will wait a short while when attempting to upload. So you can press the reset and hold it until the Ide shows attempting to upload. then let go of it.

The problem can be that when you click upload the Ide first compiles then at the end of the process attempts to upload. So pressing reset, clicking compile and immediately letting go of reset doesn't always work because you let go of the reset too quickly.

Upvotes: 0

lokers
lokers

Reputation: 2198

If you run across the same problem with Arduino Yun, try uploading empty sketch using WIFI as port. It worked for me when I couldn't upload new sketch via USB.

Upvotes: 0

RKNAYAK
RKNAYAK

Reputation: 55

Upload your boot loader using Avr pocket programmer. This solves your MCU reset. Use Watchdog timer instruction while coding infinite loop provided you are dealing with critical parameter to be written when it restarts.

Upvotes: 0

Colton
Colton

Reputation: 645

Remove the USB connection, close the IDE, open the IDE, open BareMinimum, hold the reset button, plugin the USB connection, click the upload button 1/2 a second after removing your finger from the reset button.

Upvotes: 12

ViennaMike
ViennaMike

Reputation: 2337

If you're using an Arduino Uno, you might want to check out Updating the Atmega8U2 on an Uno or Mega2560 using DFU. Apparently there was a bug in the interface firmware.

Upvotes: 9

Sean Sheedy
Sean Sheedy

Reputation: 61

Reprogramming the interface firmware (see ViennaMike's response) did not work for me, so I purchased another Arduino and turned it into an ISP programmer and overwrote the offending application:

https://stackoverflow.com/a/8453576/1090713

While this approach had some cost, I now have another tool and a way to save an Arduino in the future.

Upvotes: 1

JoeSlav
JoeSlav

Reputation: 4815

This may sounds silly but what about disconnect it from the power supply to reset the MCU?

Edit:

I see it is powered via USB; then make sure you disconnect the device, remove/discharge any battery/capacitors whatsoever. If nothing works, close down the Arduino IDE, change the USB port you are using (sometimes it does happen that they get stuck..), reboot the PC.. Good luck!

Upvotes: 1

Related Questions