![]() |
There are times when a program just needs to give up and ask for human assistance. Suppose a sensor or motor becomes disconnected or the battery is dying or perhaps there is a bug in the code which leads down a dark and dangerous code alley. Below is a short piece of code that provides an error routine which will halt the chip and blink an LED, in this case pin PORTB5 (Arduino pin 13), with up to 14 error codes. Ideally, the function can be called if the program determines it's in a unrecoverable state and can provide a code to tell the programmer where it failed. |