The bootloader was designed so that the user program can detect brown-out resets. To do so, check
to see if the BORF bit in the MCUSR register is set, and then clear it later. Here is some example code
you could put in your
setup
function for detecting brown-out resets:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
pinMode(13, OUTPUT);
if
(MCUSR & (1 << BORF))
{
// A brownout reset occurred.
Blink the LED
// quickly for 2 seconds.
for
(uint8_t i = 0; i < 10; i++)
{
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
}
}
MCUSR = 0;
Pololu Balboa 32U4 Balancing Robot User’s Guide
© 2001–2019 Pololu Corporation
9. The A-Star 32U4 Bootloader
Page 91 of 97