Rest of Basic in simple English. Reconsider some code samples?
This commit is contained in:
Родитель
9c96591edd
Коммит
21361708ec
|
@ -1,6 +1,7 @@
|
|||
# Forever
|
||||
|
||||
Repeat code [in the background](/reference/control/in-background) forever.
|
||||
Keep running part of a program
|
||||
[in the background](/reference/control/in-background).
|
||||
|
||||
```sig
|
||||
basic.forever(() => {
|
||||
|
@ -9,7 +10,9 @@ basic.forever(() => {
|
|||
|
||||
### Example: compass
|
||||
|
||||
The following example constantly checks the [compass heading](/reference/input/compass-heading) and updates the screen with the direction.
|
||||
The following example constantly checks the
|
||||
[compass heading](/reference/input/compass-heading)
|
||||
and updates the screen with the direction.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
|
@ -30,7 +33,9 @@ basic.forever(() => {
|
|||
|
||||
### Example: counter
|
||||
|
||||
The following example continually shows the current value of a global variable:
|
||||
The following example keeps showing the [number](/reference/types/number) stored in a global variable.
|
||||
When you press button `A`, the number gets bigger.
|
||||
You can use a program like this to count things with your BBC micro:bit.
|
||||
|
||||
```blocks
|
||||
let num = 0
|
||||
|
@ -42,9 +47,12 @@ input.onButtonPressed(Button.A, () => {
|
|||
})
|
||||
```
|
||||
|
||||
### Contention for the LED display
|
||||
### Competing for the LED screen
|
||||
|
||||
If you have multiple processes that each show something on the LED screen, you may get unexpected results. Try, for example:
|
||||
If different parts of a program are each trying
|
||||
to show something on the LED screen at the same time,
|
||||
you may get unexpected results.
|
||||
Try this on your micro:bit:
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# Pause
|
||||
|
||||
Pause program execution for the specified number of milliseconds. This function is helpful when you need to slow down your program's execution.
|
||||
Pause the program for the number of milliseconds you say.
|
||||
You can use this function to slow your program down.
|
||||
|
||||
```sig
|
||||
basic.pause(400)
|
||||
|
@ -8,11 +9,13 @@ basic.pause(400)
|
|||
|
||||
### Parameters
|
||||
|
||||
* ``ms`` - the number of milliseconds that you want to pause (100 = 1/10 second, 1000 milliseconds = 1 second)
|
||||
* ``ms`` is the number of milliseconds that you want to pause (100 milliseconds = 1/10 second, and 1000 milliseconds = 1 second).
|
||||
|
||||
### Example: diagonal line
|
||||
|
||||
The following example code turns on LED `0, 0` thru `4, 4`, pausing 500 milliseconds after each LED. Without `pause`, the code would run so fast that you wouldn't see each individual LED turning on.
|
||||
This example draws a diagonal line by turning on LED `0, 0` (top left) through LED `4, 4` (bottom right).
|
||||
The program pauses 500 milliseconds after turning on each LED.
|
||||
Without `pause`, the program would run so fast that you would not have time to see each LED turning on.
|
||||
|
||||
```blocks
|
||||
for (let i = 0; i < 5; i++) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче