The micro:bit can sometimes run out of resources. When it does this, it enters a 'panic' routine, which displays a sad face on the micro:bit screen followed by a number. The micro:bit runtime documentation contains a list of the codes.


enum PanicCode{
    // PANIC Codes. These are not return codes, but are terminal conditions.
    // These induce a panic operation, where all code stops executing, and a panic state is
    // entered where the panic code is diplayed.

    // Out out memory error. Heap storage was requested, but is not available.
    MICROBIT_OOM = 20,

    // Corruption detected in the micro:bit heap space

    // Dereference of a NULL pointer through the ManagedType class,


The Javascript Blocks Editor attaches additional information into the error code (e.g. 042 is a more refined version of 040). These are listed within the Makecode reference documentation and on the website

What can I do to fix it?

If you are using one of the standard languages such as Javascript Blocks or MicroPython, you would not normally see these error messages. If you do, please report them to us so we can investigate. Error 20 is possible if your program is very complex and is using a lot of very large variables (basically you have run out of RAM memory).

If you are using C++, then these errors are more likely if you have a bug in your C++ program.

In all cases, pressing the reset button on the back of the micro:bit will restart the program, which clears out the RAM memory and starts again.

Keywords for search: sad face, error, error codes, panice code, 020