This commit is contained in:
Peli de Halleux 2016-06-23 23:23:16 -07:00
commit f3bfd41a75
2 changed files with 36 additions and 7 deletions

View File

@ -1,8 +1,37 @@
# Reset # Reset
Reset the BBC micro:bit (as if you pushed the reset button on the back of the device), which causes the program to start again. Reset the BBC micro:bit and start the program again.
This function is like pressing the reset button on the back of the micro:bit.
```sig ```sig
control.reset() control.reset()
``` ```
### 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)

View File

@ -9,19 +9,20 @@ pins.analogReadPin(AnalogPin.P0)
### Parameters ### Parameters
* a [string](/reference/types/string) that stores the pin you say (`P0` through `P4`, or `P10`) * a [string](/reference/types/string) that stores the name of the pin
you say (`P0` through `P4`, or `P10`)
### Returns ### Returns
* a [number](/reference/types/number) from `0` through `1024` * a [number](/reference/types/number) from `0` through `1023`
This program reads pin `P1` and shows the number as a This program reads pin `P1` and shows the number
[bar graph](/reference/led/plot-bar-graph). on the LED screen.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
let value = pins.analogReadPin(AnalogPin.P1) let value = pins.analogReadPin(AnalogPin.P1)
led.plotBarGraph(value, 1023) basic.showNumber(value)
}); });
``` ```
@ -32,4 +33,3 @@ basic.forever(() => {
[analog write pin](/reference/pins/analog-write-pin), [analog write pin](/reference/pins/analog-write-pin),
[digital read pin](/reference/pins/digital-read-pin), [digital read pin](/reference/pins/digital-read-pin),
[digital write pin](/reference/pins/digital-write-pin) [digital write pin](/reference/pins/digital-write-pin)