2016-03-26 00:47:20 +01:00
|
|
|
# Reset
|
|
|
|
|
2016-11-01 18:42:42 +01:00
|
|
|
Reset the @boardname@ and start the program again.
|
2016-06-24 00:25:56 +02:00
|
|
|
|
|
|
|
This function is like pressing the reset button on the back of the micro:bit.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```sig
|
|
|
|
control.reset()
|
|
|
|
```
|
|
|
|
|
2016-06-24 00:25:56 +02:00
|
|
|
### Example
|
|
|
|
|
|
|
|
This program will count as high as you like when you press button `A`.
|
|
|
|
When you get tired of counting, press button `B` to reset the
|
|
|
|
micro:bit and start the program over.
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
let item = 0;
|
|
|
|
basic.showNumber(item);
|
|
|
|
input.onButtonPressed(Button.A, () => {
|
|
|
|
item = item + 1;
|
|
|
|
basic.showNumber(item);
|
|
|
|
});
|
|
|
|
input.onButtonPressed(Button.B, () => {
|
|
|
|
control.reset();
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
#### ~hint
|
|
|
|
|
|
|
|
This program works better on a real micro:bit than in the simulator.
|
|
|
|
|
|
|
|
#### ~
|
|
|
|
|
|
|
|
### See Also
|
|
|
|
|
|
|
|
[clear screen](/reference/basic/clear-screen), [game over](/reference/game/game-over)
|