Hi, I am using an Arduino Uno and I need to evaluate what has been the cause of the reset, I am using this code but I always have the register MCUSR value equal to 2, what could be my error?
The bootloader runs before your sketch, and resets the flag for the cause of the reset. Optiboot can pass the data to your code, but you need a more recent version than the one shipped on the UNO.
Does not help that the old example code of test_reset.ino seems to no longer exist.
This looks like the current example code, note that it REQUIRES a newer version of optiboot than the standard one on an UNO.