pxt-calliope/docs/reference/basic/show-number.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

1.3 KiB

Show Number

Show a number on the LED screen. It will slide left if it has more than one digit.

basic.showNumber(2)

Parameters

  • value is a Number. If the number is not single-digit number, it will scroll on the display.
  • interval is an optional Number. It means the number of milliseconds before sliding the value left by one LED each time. Bigger intervals make the sliding slower.

Examples:

To show the number 10:

basic.showNumber(10)

To show the number stored in a variable:

let x = 1
basic.showNumber(x)

Example: count to 5

This example uses a for loop to show numbers 0 through 5 on the screen:

for (let i = 0; i < 6; i++) {
    basic.showNumber(i)
    basic.pause(200)
}

Advanced

If value is NaN (not a number), ? is displayed.

Other show functions

See also

show string, show animation, Number, math