$USD
  • EUR€
  • £GBP
  • $USD
TUTORIALS micro:bitMicroPython

micro:bit MicroPython: Software reset

DFRobot Apr 09 2019 490

In this microbit tutorial we will learn how to perform a software reset on the Micro:bit, using MicroPython.

Introduction

In this tutorial we will learn how to perform a software reset on the Micro:bit, using MicroPython.

For this tutorial, we will use the microbit module, which we have also been using in some previous tutorials. Amongst other features, the microbit module exposes a function that allows us to perform a software reset to our device.

The code

The code for this tutorial will be very simple and short, since we just need to include a module and call a function.

So, as mentioned, the first thing we will do is importing the microbit module, so we have access to the function that will allow us to reset the device

import microbit

After importing the microbit module, we will have access to the reset function. This function takes no arguments and resets the device.

microbit.reset()

The full code for this script can be seen below.

import microbit
 
microbit.reset()

Testing the code

To test the code, simply run the previous two lines of code in your Micro:bit device, using a tool of your choice. In my case, I’ll be using uPyCraft, a MicroPython IDE.

Upon running the code, you should get a result similar to figure 1. As can be seen, after executing the call to the reset function, the device was reset.

After the reset, the board is restarted, an informative message regarding the software / hardware is printed and the prompt becomes available again.

REVIEW