Go Down

Topic: Sketch after Arduino Uno power off (Read 2 times) previous topic - next topic


I hope someone can explain to me the bold part:

Why doesn't my sketch start when I power up or reset the Arduino board?
Most likely because you are sending serial data to the board when it firsts turns on. During the first few seconds, the bootloader (a program pre-burned onto the chip on the board) listens for the computer to send it a new sketch to be uploaded to the board. After a few seconds without communication, the bootloader will time out and start the sketch that's already on the board. If you continue to send data to the bootloader, it will never time out and your sketch will never start. You'll either need to find a way to stop serial data from arriving for the first few seconds when the board powers (e.g. by enabling the chip that sends the data from within your setup() function) or burn your sketch onto the board with an external programmer, replacing the bootloader.

What does it mean? I've tried to "freeze" my sketch by using delay and millis functions, but sketch still won't load after power off.


I don't think it means anything, a brain fart ?.  Since it is the arduino that is receiving, you either need to stop or disconnect whatever is sending the data whilst it starts up or remove the bootloader and burn the sketch directly with a programmer.  Since the sketch never starts if the serial is receiving, nothing you put in the sketch can make any difference. 


I have tried to unplug all the connected wires from Arduino after power down, power up the Arduino and connect wires again, but it still won't load the sketch. This is highly annoying.


That seems like one of the bugs of the UNO bootloader.
In fact, after you put a sketch inside the Atmega it will be there for ever and ever, and you can receive all the serial data that you want, because the bootloader as a pretty specific command set to avoid that kind of problems.


Go Up