I'm working on a project and my dad hit the reset button on my Arduino board, unknowingly. If it wasn't connected to any power source or computer, did it still reset? Do I have to upload my code to the board again? Or does the board need power to be reset?
1 Answer
The reset on an Arduino does not erase anything. It merely restarts execution of an already uploaded program. Also the AVR needs to be powered on for it to realize whether it has been reset.
Every time you power on an Arduino it automatically starts code execution from the beginning of the program in the flash memory.
-
Everything in RAM (non persistant memory) will be erased. progmem/flash and EEPROM are persistant and will not be erased.– aaaCommented Apr 6, 2017 at 6:37
-
you can't erase RAM any more than you can erase a projector screen; electrons+photons erase themselves.– dandavisCommented Apr 6, 2017 at 9:57
-
4Actually, pressing RESET doesn't erase RAM. It resets the CPU and sets all SFRs to power-on defaults, but the RAM remains the same. It's the code that is added to the start of your program (
crt0.o
) that erases the BSS area and copies any other defaults into place from flash. The rest of RAM continues to hold what was in there before. Of course, with no power applied it's all rubbish anyway, since nothing is happening.– MajenkoCommented Apr 6, 2017 at 10:08