pxt-calliope/docs/reference/basic/pause.md
Juri Wolf 5f7a8e5301
Updates for V4 (#197)
* update yotta defaults for 16kb devices

* refactor deprecated blocks

* updates for button events

* update button events

* update refference

* update docs

* update docs

* update button event blocks

* update docs

* update block id
2022-08-10 09:36:19 -07:00

878 B

Pause

Pause the program for the number of milliseconds you say. You can use this function to slow your program down.

basic.pause(400)

Parameters

  • ms is the number of milliseconds that you want to pause (100 milliseconds = 1/10 second, and 1000 milliseconds = 1 second).

Example: diagonal line

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.

for (let i = 0; i < 5; i++) {
    led.plot(i, i)
    basic.pause(500)
}

Advanced

If ms is NaN (not a number), it will default to 20 ms.

See also

while, running time, for